I'm trying to make a get request to an api,but there is en error: Failed to fetch, what might be wrong here?
const getData = () => {
fetch("https://test-docs.stores.kg/api/categories", {
method: "GET",
headers: {
secretKey: "test_key",
accept: "application/json "
}
})
.then((res) => res.json())
.then((res) => console.log(res));
};
getData();
Seems like the API you're querying is not setting a CORS header (check for reference https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). Therefore your request is being blocked.

If you are in control of this API adjust the webserver settings to set the appropriate header: e.g.
You can also test the API in this Tool here https://www.test-cors.org/#?client_method=GET&client_credentials=false&server_url=%20https%3A%2F%2Ftest-docs.stores.kg%2Fapi%2Fcategories&server_enable=true&server_status=200&server_credentials=false&server_tabs=remote