Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

259
Visualizações
What the difference between these two API calls?

I am trying to upload an image. Normally I use axios call api. Since This call is not working with axios I tried with fetch.

I want to know what the difference between these two

Here are these two.

Axios // API CALL WITH NOT SUCCESSFUL WITH THIS ONE

axios
  .post(
    "userapi/UpdateUserProfileImage",
    {
      body: createFormData(photo, {}),
    },
    {
      headers: {
        "Content-Type": "multipart/form-data",
      },
    }
  )
  .then((res) => console.log(res.data))
  .catch((err) => console.log(err.response.data.Message));

Here is the fetch method. // this will successful

fetch("userapi/UpdateUserProfile", {
  method: "POST",
  headers: new Headers({
    "Content-Type": "multipart/form-data",
  }),
  body: createFormData(photo, {}),
})
  .then((data) => data.json())
  .then((res) => {
    console.log("upload succes", res);
  })
  .catch((error) => {
    console.log("upload error", error);
  });

What the difference between these two?

Here is the error when I use axios to call API.

Index was out of range. Must be non-negative and less than the size of the collection

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda