Use modern JSON instead of old JSONP

This commit is contained in:
Florine W. Dekker 2021-04-24 17:06:21 +02:00
parent b749b0a4b9
commit d17af82b2a
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
3 changed files with 6 additions and 10 deletions

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "interlanguage-checker",
"version": "1.10.28",
"version": "1.11.0",
"description": "Check the consistency of MediaWiki interlanguage links in a simple overview.",
"author": "Felix W. Dekker",
"browser": "dist/bundle.js",
@ -15,19 +15,16 @@
"dev:server": "grunt dev:server",
"deploy": "grunt deploy"
},
"dependencies": {
"fetch-jsonp": "^1.1.3"
},
"devDependencies": {
"grunt": "^1.3.0",
"grunt": "^1.4.0",
"grunt-cli": "^1.4.2",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-focus": "^1.0.0",
"grunt-text-replace": "^0.4.0",
"grunt-webpack": "^4.0.2",
"webpack": "^5.33.2",
"grunt-webpack": "^4.0.3",
"webpack": "^5.35.1",
"webpack-cli": "^4.6.0"
}
}

View File

@ -1,4 +1,3 @@
import fetchJsonp from "fetch-jsonp";
import {couldNotConnectMessage, mergeStates} from "./Shared";
@ -351,9 +350,9 @@ export class MediaWiki {
* @return {Promise<Object>} the API's response
*/
request(params) {
const url = this.origin + this.apiPath + "?format=json&" + new URLSearchParams(params).toString();
const url = this.origin + this.apiPath + "?format=json&origin=*&" + new URLSearchParams(params).toString();
console.debug(`Requesting from ${this.origin}${this.apiPath} with params`, params, "at", url);
return fetchJsonp(url)
return fetch(url)
.then(it => it.json())
.catch(() => {
throw new Error(couldNotConnectMessage);