[Vuejs]-How to pass argument to nuxt $fetch?

4👍

You can’t pass custom args to fetch().

You can set up an async method() and there make your API calls.
If you need to take advantage of $fetchState.pending in order to display some placeholder while your content loads, you can set a isLoading: false property in data() and in the newly created method you set isLoading = true before you make the API call, isLoading = false after the API call.

Then in your template you can make conditionals like this: <div v-if="$fetchState.pending || isLoading">

👤sintj

Leave a comment