0

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

1 Answer 1

0

Use fetch accepts an generic type:

const { data: produto, error } = await <ProdutoInterface>useFetch(config.API_BASE_URL+`/produto`)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.