JSFiddle - React, Tailwind, and code Playground
by sperske
JavaScript
document
.querySelectorAll("grammarly-editor-plugin")
.forEach((grammarlyEditor) => {
grammarlyEditor.config = {
oauthAssertionProvider: async () => {
// Call your endpoint to get an assertion
const response = await fetch(
"your server URL?client_id=...", {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
clientId: "YOUR_CLIENT_ID"
})
})
if (!response.ok) {
throw new Error("Error creating assertion")
}
return await response.json()
}
}
})