Use isObject
This commit is contained in:
parent
ebfc7ca945
commit
018913d03f
@ -112,11 +112,7 @@ class AnkiConnect {
|
|||||||
|
|
||||||
async _invoke(action, params) {
|
async _invoke(action, params) {
|
||||||
const result = await requestJson(this._server, 'POST', {action, params, version: this._localVersion});
|
const result = await requestJson(this._server, 'POST', {action, params, version: this._localVersion});
|
||||||
if (
|
if (isObject(result)) {
|
||||||
result !== null &&
|
|
||||||
typeof result === 'object' &&
|
|
||||||
!Array.isArray(result)
|
|
||||||
) {
|
|
||||||
const error = result.error;
|
const error = result.error;
|
||||||
if (typeof error !== 'undefined') {
|
if (typeof error !== 'undefined') {
|
||||||
throw new Error(`AnkiConnect error: ${error}`);
|
throw new Error(`AnkiConnect error: ${error}`);
|
||||||
|
Loading…
Reference in New Issue
Block a user