-2

the complete was Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.jikan.moe/v3 . (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

i want to create a website of anime content and i want to fetch the data from this api address jaikan api i use react js to create this website and i write this code.

var animeData;
var apiUrl = "https://api.jikan.moe/v3";
function getData(api){
fetch(api).then((res) => res.json().then((data) => animeData = data));
}

getData(apiUrl);

and i run the react server bu simple typing npm start and then my server was started and in the console i got error

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.jikan.moe/v3 . (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

have any solution please help..

Anshu Meena
  • 119
  • 1
  • 5

1 Answers1

-1

sorry for this but after 2 days now i found the answer of this question sometime we make mistake in api uri i i use

var apiUrl = 'https://api.jikan.moe/v3/';

and i reality it was

var apiUrl = "https://api.jikan.moe/v3"

i use / this make a mistake in my code now it work perfectly

Anshu Meena
  • 119
  • 1
  • 5