From b1b33f8beb26f97d91cb282682472c65f6eccae8 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 2 Aug 2020 13:30:55 -0400 Subject: 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 --- ext/bg/js/anki.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'ext/bg/js/anki.js') 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 . */ -/* 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') { -- cgit v1.2.3