1

I get a simple list of categories from the server using async await, everything works fine. Next, I need to output a simple list of v-for, then I get this warning. I can remove all the contents of the ul tag and the error still remains, removing the v-for the error disappears. The tags are native, I make a request to the server using useFetch . The data is coming, I see them, everything about is displayed correctly.

What can I do?

<template>
<ul class="filter-item-list">
                <li v-for="item in categories" :key="item.id" >
                    <label class="radio" @click.stop="typeProduct=item.attributes.Title" >
                        <input type="radio" name="typeProduct" :checked="item.attributes.DefaultCategory">
                        <span class="icon"></span>
                        <span class="text">{{ item.attributes.Title }}</span>
                    </label>
                </li>
            </ul>
</template>

<script setup lang="ts">
const {categories, getCategories} = useCatalog()

await getCategories()
</script>

//pinia side

 actions: {
        async getCategories() {
            interface responseType {
                data: categoryType[],
                meta: []
            }

            useMain().$state.isLoading = true;
            const {data, error} = await useFetch(`${useRuntimeConfig().public.strapi.url}/api/categories`,
                {
                    method: "GET",
                    headers: {
                        "Content-Type": "application/json",
                    },
                })
            if (error.value) {
              
            } else {

              this.categories = (data.value as responseType).data
            }
            useMain().$state.isLoading = false;
        }}

enter image description here

Frallen
  • 405
  • 5
  • 14
  • Give a try to that one: https://stackoverflow.com/q/47862591/8816585 – kissu Apr 11 '23 at 11:20
  • 1
    You'd have to check that `categories` has the same value in both server & client sides. It's likely that you don't have the same number of items in the array on server. Maybe it's not loaded correctly on server side. – Kapcash Apr 12 '23 at 07:01

0 Answers0