Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncData as Nuxt #382

Open
baha96 opened this issue Apr 2, 2020 · 3 comments
Open

asyncData as Nuxt #382

baha96 opened this issue Apr 2, 2020 · 3 comments

Comments

@baha96
Copy link

baha96 commented Apr 2, 2020

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?

@tomphilpotts
Copy link

Hey,

I ran into this problem too, I've been working on a boilerplate ssr to test a few things out.

Take a look: https://github.com/BoldAnchor/Vue-SSR-Boilerplate

I am using: https://github.com/Akryum/vue-cli-plugin-ssr

It's a working progress...

@baha96
Copy link
Author

baha96 commented Apr 7, 2020

Hey,

I ran into this problem too, I've been working on a boilerplate ssr to test a few things out.

Take a look: https://github.com/BoldAnchor/Vue-SSR-Boilerplate

I am using: https://github.com/Akryum/vue-cli-plugin-ssr

It's a working progress...

the template generated an error

./src/entry-client.js 3:0-9
"export 'createApp' was not found in './main'
...
./src/entry-server.js 16:14-23
"export 'createApp' was not found in './main'

removing main.js from your codes, you removed the extra code....(I could not even check)

@tomphilpotts
Copy link

the template generated an error

./src/entry-client.js 3:0-9
"export 'createApp' was not found in './main'
...
./src/entry-server.js 16:14-23
"export 'createApp' was not found in './main'

removing main.js from your codes, you removed the extra code....(I could not even check)

I pushed an update around the same time you posted. Should be fine, I'm not getting an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants