Skip to content

Instantly share code, notes, and snippets.

@linonetwo
Created May 24, 2019 08:02
Show Gist options
  • Save linonetwo/6ca147d2c52da2258cebfa50e4c720be to your computer and use it in GitHub Desktop.
Save linonetwo/6ca147d2c52da2258cebfa50e4c720be to your computer and use it in GitHub Desktop.
ES6 fetch #api with headers and body
fetch(`http://localhost:${env.ankiPort || 8765}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ action: 'addNote', version: 6, params }),
}).catch(error => {
pluginContext.console.log('error', 'failed adding to anki', { error, errorString: String(error) });
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment