You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like how there's a demonstration of hooks, and some documentation. It'd be cool if that was the "advanced" section/post about hooks. It'd be great if there was a very simple hooks example -- some async data fetches. The docs (or the post, don't remember which off-top) -- show an example of an async data fetch, in a code-block. So we could put that, or a dummy of that, in the template.
I'd just do a PR, but I'm actually suggesting this because I'm blocked. I think I'm missing something[s] obvious, as I'm rusty on full-stack JS, and bundlers.
Thoughts? Suggestions?
The text was updated successfully, but these errors were encountered:
haha, this is a good request indeed. for what its worth my site is in elderjs so perhaps a little less meta for you. https://github.com/sw-yx/swyxdotio/
// ./src/hooks.jsconstfetch=require('node-fetch');module.exports=[{hook: 'bootstrap',name: 'addExternalData',description: 'Adds arbitrary external data to the data object available in all hooks and routes.',run: async({ settings, data })=>{constexternalData=awaitfetch('https://yourapi.here').then((res)=>res.json());return{data: {
...data,
externalData,// this data is now available in the `all` and `data` functions of your `/routes/routeName/route.js`.},};},},};
I like how there's a demonstration of hooks, and some documentation. It'd be cool if that was the "advanced" section/post about hooks. It'd be great if there was a very simple hooks example -- some async data fetches. The docs (or the post, don't remember which off-top) -- show an example of an async data fetch, in a code-block. So we could put that, or a dummy of that, in the template.
I'd just do a PR, but I'm actually suggesting this because I'm blocked. I think I'm missing something[s] obvious, as I'm rusty on full-stack JS, and bundlers.
Thoughts? Suggestions?
The text was updated successfully, but these errors were encountered: