-4

I am working on nextjs(reactjs framework) Right now i want to know the difference betweeen "axios" and "await fetch" ? In which situation we should use "axios" ? For example here is my code

 const response = await fetch(`/api/comments/${commentId}`, {
      method: 'DELETE'
    })
Jens
  • 67,715
  • 15
  • 98
  • 113
  • That's a topic for Google (or your preferred search provider) -> [What topics can I ask about here?](https://stackoverflow.com/help/on-topic), [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) – Andreas Jan 05 '23 at 07:10

1 Answers1

-2

Different properties are used for a post request to send data to the endpoint - Axios uses the data property, whereas with fetch we use the body property. We need to serialize data into a JSON string to send data. Axios automatically stringifies data when sending JavaScript objects to the API using the POST method.

for more information you can check form this https://codilime.com/blog/axios-vs-fetch/#:~:text=Different%20properties%20are%20used%20for,API%20using%20the%20POST%20method.