So I'm having an issue with the npm package axios when trying to make a get request to a URL. I get an error code 503 every time; this is my code:
let data, response;
response = await axios.get(url, {
headers: {
Accept: 'application/json',
}
})
So at first, I thought I did something wrong with the code (like changing Accept to 'Accept'), but when I do the exact same thing on Postman, it returns just fine.
So I tried by changing the User-Agent option in the headers to the one from Postman, and now it just seems to be working.
let data, response;
response = await axios.get(url, {
headers: {
'Accept': 'application/json',
'User-Agent': 'PostmanRuntime/7.28.4',
}
});
I'm still a bit new to http requests, so I really don't understand how this happens. I'm using axios in other cases with different URL's too and there everything just runs fine.