marcelo.delta
marcelo.delta

Reputation: 3082

How to assign an interface to a useFetch object Vuejs 3 and Nuxtjs 3

How to assign an interface to a useFetch object Vuejs 3

Interface

export interface ProdutoInterface {
  codigo: number
  nome: string
}

Componente

const { data: produto, error } = await useFetch(config.API_BASE_URL+`/produto`)

I can't get it to work. Would anyone know how to help me.

thank you very much for your attention

Upvotes: 0

Views: 730

Answers (1)

Ilijanovic
Ilijanovic

Reputation: 14904

Use fetch accepts an generic type:

const { data: produto, error } = await <ProdutoInterface>useFetch(config.API_BASE_URL+`/produto`)

Upvotes: 0

Related Questions