System Information
- Strapi Version: 4.11.5
- Operating System: Win/Mac
- Database: SQLite
- Node Version: 18
- NPM Version:
- Yarn Version:
I don’t know if I am going about this in all the wrong way.
I have a folder with my node js app in and another folder with strapi in
myNodeApp
>node_modules
>models
>controllers
>routers
>views
app.js
...etc
myNodeAppStrapi
>.cache
>.tmp
>build
>node_modules
...etc
I am able to fetch data from the localhost:1337 server, using quite horrible code.
await fetch('http://127.0.0.1:1337/api/questions?populate[options][populate][0]=icon')
I don’t like the need to populate, feel it should be configurable at source.
I see that there other more declarative methods available for fetching data that strapi provides e.g.
strapi.db.query('api::blog.article').findMany({ // uid syntax: 'api::api-name.content-type-name'
where: {
title: {
$startsWith: '2021',
$endsWith: 'v4',
},
},
populate: {
category: true,
},
});
I do not know how I access these features from myNodeApp. Where or what to import to access this functionality.
Is having separate folders wrong?
Am I barking up the wrong tree trying to build an app in Node JS using Strapi for the backend? I don’t see many tutorials. Most are React/Next etc.