Skip to content

asyncData as Nuxt  #382

Open
Open
@baha96

Description

@baha96

how to implement as nuxt AsyncData, for example:

async asyncData({ route }) {
           try { 
                const { results }= await axios.get('/blog/', { page: route.query.page || '1' });
                return {
                    items: results,
                    query: {
                       page: route.query.page || '1'
                   }
               };
            } catch (e) {
                return {
                    items: [],
                    query: {
                        page: route.query.page || '1'
                    }
               }
            }
 },
watchQuery: true,

and then inside the template call items without use store

==================
and how to use it here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions