const credential = await navigator.credentials.create({
publicKey: createCredentialOptions,
});
const json = credential.toJSON();
console.log(json); // A plain object
console.log(typeof json); // "object"
console.log(json.id); // Same value as credential.idPublicKeyCredential: toJSON() method / notebook
PublicKeyCredential: toJSON() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const jsonString = JSON.stringify(credential);
console.log(jsonString);
const registrationURL = "https://example.com/registration";
const apiRegOptsResp = await fetch(registrationURL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: jsonString,
});