is anyone getting acquainted with the RAWG video game platform API ?
error: Access to XMLHttpRequest at 'https://api.rawg.io/api/platforms?key=YOUR_API_KEY' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.*
I searched on the Internet, the problem for those who use react is that they call in the hook
useEffect(() => {
fetchAndStoreData();
});
without [ ] which leads to an endless launch of requests to the RAWG API and the limit of 2000 requests ends almost instantly and the server disables access. So in the case of a react, it is correct to call the function in the hook with [ ] something like this
useEffect(() => {...}, []);
can i have this problem in vue3 ? if so, how to fix it? or is it something else? i thank you
my code
actions: {
async fetchGames() {
const options = {
method: 'GET',
url: 'https://api.rawg.io/api/platforms?key=YOUR_API_KEY',
}
try {
const response = await $axios.request(options)
this.games = response.data.requests
console.log(this.games)
} catch (error) {
console.log(error)
}
},
},
onMounted(async () => {
await $gamesStore.fetchGames()
games.value = $gamesStore.games
console.log(games.value)
})