Reputation: 3082
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
Reputation: 14904
Use fetch accepts an generic type:
const { data: produto, error } = await <ProdutoInterface>useFetch(config.API_BASE_URL+`/produto`)
Upvotes: 0