Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Nuxt 3 + Strapi 4 + TypeScript error

Chiusa
#461 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
nuxt, typescript
Ambito
api, frontend

Direzione di ricerca

Esamina i tipi restituiti da useStrapi find e findOne insieme alla dichiarazione Header_Plain generata e all’assegnazione in loadData. Riproduci l’errore TypeScript con la configurazione Nuxt 3 e Strapi 4 mostrata, quindi verifica che la forma dei dati restituiti e il tipo ref dichiarato corrispondano.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

question triage

Hello there!

I am fairly new to TypeScript and I wanted to create a Nuxt 3 app with Strapi 4 with TypeScript. On Strapi I have plugins "strapi-plugin-transformer" for flattening my response and "shemas-to-ts" for generating TS types. So far everything worked quite well but now I have been stuck for a while on, I bet pretty simple stuff. I have single type in Strapi called Header and I am trying to load all data on FE. I took the generated type from Strapi which looks like this:

export interface Header_Plain {
    id: number;
    createdAt: Date;  updatedAt: Date;  publishedAt?: Date;  logo: Media_Plain;
    Link: HeaderLink_Plain[];
    locale: string;
    localizations?: Header_Plain[];
}

then, in my Nuxt, I have this code:

<script setup lang="ts">
const { find } = useStrapi()

const headerData = ref<Header_Plain | null>(null)

const { data, execute } = await useAsyncData(
  'header',
  () => find<Header_Plain>('header', { populate: 'deep' })
)

function loadData() {
  execute()

  headerData.value = data.value?.data
}

onMounted(() => {
  loadData()
})
</script>

The problem I have is, that I get the data from BE but in my loadData function I am getting Vue: Type Strapi4ResponseData<Header_Plain>[] is not assignable to type error. I know that I probably should use findOne instead of find but when I use findOne the problem still occurs. Could anyone help me with this? I simply don't understand why my BE data are wrapped in this Strapi4ResponseData or how I should take them out.

Lingua principale
TypeScript
Stelle
718
Fork
90
Merge medio
13h 11m
PR unite (30g)
12

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nuxt-modules/strapi

Tutte le issue di nuxt-modules/strapi

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.