the preacher
the preacher

Reputation: 377

axios returns 500 while postman returns 200

I am trying to call an API using axios but the problem is that it keeps returning 500 while postman is returning 200.

I've tried using fetch too but the result didn't change. Here's my code and I hope you can help me out on this one. and also I'm using a proxy in my package.json to get past the CORS errors.

let headers = {
    'Authorization': 'a',
    'Accept': 'application/json'
}

axios.get("v1/index-items", { headers: headers })
    .then(res => {
        console.log(res)

    })

Upvotes: 0

Views: 1102

Answers (1)

Konstantin Kim
Konstantin Kim

Reputation: 239

The problem can be in two things: wrong request URL, or CORS problems. In the second case, you need to configure CORS on your backend. Try to look at the headers on the response, are all needed headers there? Try to look in the developer console, there should be CORS error.

Upvotes: 1

Related Questions