I am trying to implement a tool to help me filter through posts more easily, and I am trying to pull posts from the site, however the fetch command always returns an error. I have looked up these errors and I cannot find a method to get it to return anything.
In the past, I have used the endpoint specified in a promised fetch, looking like this on my first attempt:
fetch("https://www.e621.net/posts.json?tags=male&limit=5", {mode: 'no-cors'}) .then(response => { if(response.ok) return response.json() throw new Error("Request failed") }, networkError => {console.log(networkError.message)}) .then(jsonResponse => {console.log(jsonResponse)})
However, this threw an error of "Request failed". I could not find anything wrong with my breakpoint or policy, so I added a console log for response, and I get an object that doesn't have the ok status. I did some googling, and found out that the no-cors policy is causing the returned response to be opaque, meaning it doesn't have a body to process. However, when I remove this header there is an error saying that I do not have access to the endpoint. I have even tried adding the credentials for my user as a header, but it also didn't help.
Other programs I have written use other endpoints and I have not come across this issue with them before. What should I do?