0

I have this Axios call in my React component to save a 'team' object to an API which then saves to the database.

const updateTeam = async (team) => {
    await axios({
        method: "PUT",
        url: "api/teams/" + team.id,
        data: JSON.stringify(team),
        headers: { 'Content-Type': 'application/json; charset=utf-8' }
    });
};

And I call it like this:

updateTeam(updatedTeam);

When I run it, I get this error:

PUT https://localhost:44376/api/teams/50 400

createError.js:16 Uncaught (in promise) Error: Request failed with status code 400
    at createError (createError.js:16)
    at settle (settle.js:17)
    at XMLHttpRequest.handleLoad (xhr.js:61)

And that's all I get.

I even put a breakpoint in my API backend, but it is never hit at all.

Is there a way to get a more detailed error from Axios?

Thanks!

SkyeBoniwell
  • 6,345
  • 12
  • 81
  • 185

0 Answers0