I get this response when I try to use Wikipedia API
Response {type: "cors", url: "https://en.wikipedia.org/w/api.php?action=opensear…amespace=0&format=json&origin=*&utf8=&format=json", redirected: false, status: 200, ok: true, …}
The correct response is a JSON format of requested data, but I can't get it!
Here's my code:
let link = `https://en.wikipedia.org/w/api.php?action=opensearch&search=google&limit=20&namespace=0&format=json&origin=*&utf8=&format=json`;
fetch(link)
.then((res)=>{console.log(res);return res;})
Can anyone help me?
try this:MDN
let link = `https://en.wikipedia.org/w/api.php?action=opensearch&search=google&limit=20&namespace=0&format=json&origin=*&utf8=&format=json`;
fetch(link)
.then(res => res.json())
.then(data => console.log(data));