1
  1. Why in the official document do they use both fetch and axios in fetch function?

Just because it needs to return a Promise?

  1. can we use fetch API in asyncData function? Does it make sense?

fetch example in official document

2 Answers 2

3

There no use of fetch in docs that you linked. There only fetch function that defined for nuxt itself.

You can use http fetch instead of axios, but it wont work on node. You will need to use polyfill for node like node-fetch

Basically you can use any library you want to get your data. Axios just used as a most common library that is used for that purpose. There nothing specific to axios in nuxt itself

0
0

what I know the process is

  1. get ( fetch ) the data with axios or node-fetch with node platform to the server ( hold data on the server )
  2. build the first page for the client and pre-render from server
  3. then client save the data, and SPA works.

so we can't use fetch because fetch methods is the native way only on the browser. Correct me if I'm wrong. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.