User:Sarthak Kundra/task3.js

// Mediawiki API tutorial to check // checkModule API // Checking a CSRF token.

var url = "https://en.wikipedia.org/w/api.php";

var params = { action: "checktoken", token: "123ABC", type: "csrf", format: "json" };

url = url + "?origin=*"; Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});

fetch(url) .then(function(response){return response.json;}) .then(function(response) {console.log(response);}) .catch(function(error){console.log(error);}); // Note:- Insi=pired from documentation and eamples.