-1

I am new to Node. I saw many examples on Rapid API where we use the axios package to make requests to an API. But we can also do the same with fetch method in JavaScript frontend. So should I make API requests from frontend JavaScript using fetch or should I use my backend to make API requests using axios?

Thank you in advance for any help!

Meet Shah
  • 612
  • 1
  • 6
  • 13

1 Answers1

-1

1)Axios has url in request object while Fetch has no url in request object.

2)Axios is a stand-alone third party package that can be easily installed while Fetch is built into most modern browsers no installation is required as such.

3)Axios enjoys built-in XSRF protection but Fetch does not.

4)Axios uses the data property while Fetch uses the body property.

5)Axios data contains the object while Fetch’s body has to be stringified

6)Axios has the ability to intercept HTTP requests but Fetch, by default, doesn’t provide a way to intercept requests.

Go through this article and you will understand https://www.geeksforgeeks.org/difference-between-fetch-and-axios-js-for-making-http-requests/

  • The article gives information about the two technologies. But I am still confused whether to make calls from frontend or backend. For example, I am making a Music Player using React. I want to make an API call to a website to get a song. So should I make the call from the React component in the frontend or should I make my backend make the call using Axios? – Meet Shah Dec 05 '21 at 04:29
  • Please see [Your answer is in another castle: when is an answer not an answer?](https://meta.stackexchange.com/questions/225370/your-answer-is-in-another-castle-when-is-an-answer-not-an-answer) – ggorlen Dec 05 '21 at 04:40