I’m trying to fetch the data of specific posts in Discourse. But while trying to do that, I’m getting the error that access is restricted, so I proceeded to add my API keys to the header. To do that I’ve written the following code:
axios.get(`{myURL}/posts/${pid}.json`, { 'mode': 'cors', headers: { Authorization: '{myAPIKey}' }}) .then(function (response) { consol.log(response) setPostData(response.data?.topic_list?.topics) }) .catch(function (error) { console.log(error) }) I’ve already added CORS to de Discourse server to allow requests from my server. Issue with this is that now I’m getting a CORS error which says the following: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
I don’t understand what may I have done wrong as everything seems okay