lib/app.js- Node REST API to query Cosmic JS DB
- cosmicjs-node
Cosmic.getObjects(credentials, (err, response) => {})src/app/*- Redux calls our Node API server, which in turn retrieves our Cosmic JS blog content.
npm install- Terminal 1 -
npm run start:server - Terminal 2 -
npm run start:dev - localhost:3000
- Add the following code to your
config/index.jsfile with your CosmicJS credentials.
const config = {
app: {
port: process.env.PORT || 5000
},
bucket : {
slug: process.env.SLUG || 'YOUR COSMIC SLUG',
write_key: process.env.WRITE_KEY ||'YOUR COSMIC WRITE KEY',
read_key: process.env.READ_KEY ||' YOUR COSMIC READ KEY'
}
}
module.exports = config;