diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-08-02 13:30:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-02 13:30:55 -0400 |
commit | b1b33f8beb26f97d91cb282682472c65f6eccae8 (patch) | |
tree | 1a7b5027a0f5208135f856759cb7935beac7911a /ext/bg/js/anki.js | |
parent | a562a1149808b49f60346c82409f292290fbdd77 (diff) |
Fix fetch requests (#708)
* Revert audio fetching functionality to use XMLHttpRequest
* Replace requestJson
* Replace requestJson
* Replace requestJson
* Replace requestJson and requestText
* Fix tests
* Include support for vulgar word searches
* Remove request.js
Diffstat (limited to 'ext/bg/js/anki.js')
-rw-r--r-- | ext/bg/js/anki.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js index a8872a52..a72dff2a 100644 --- a/ext/bg/js/anki.js +++ b/ext/bg/js/anki.js @@ -15,10 +15,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* global - * requestJson - */ - class AnkiConnect { constructor(server) { this._enabled = false; @@ -110,7 +106,16 @@ class AnkiConnect { } async _invoke(action, params) { - const result = await requestJson(this._server, 'POST', {action, params, version: this._localVersion}, true); + const response = await fetch(this._server, { + method: 'POST', + mode: 'cors', + cache: 'default', + credentials: 'omit', + redirect: 'follow', + referrerPolicy: 'no-referrer', + body: JSON.stringify({action, params, version: this._localVersion}) + }); + const result = await response.json(); if (isObject(result)) { const error = result.error; if (typeof error !== 'undefined') { |