PirateApp
PirateApp

Reputation: 6204

How to pass argument to nuxt $fetch?

Upvotes: 0

Views: 2468

Answers (1)

sintj
sintj

Reputation: 814

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">

Upvotes: 4

Related Questions