Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!