This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bucket = api.bucket({ | |
slug: "YOUR_BUCKET_SLUG", | |
read_key: "YOUR_BUCKET_READ_KEY", | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Cosmic = require("cosmicjs"); | |
const api = Cosmic(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bucket.objects.find | |
const data = await bucket.objects | |
.find({ | |
type: "products", // Object Type slug | |
}) | |
.props("title,slug,metadata") // response properties | |
.limit(10); // number of Objects to be returned | |
// bucket.objects.insertOne | |
const data = await bucket.objects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
const api = require('cosmicjs')() // empty init | |
const bucket = api.bucket({ | |
slug: 'docs-ecommerce-app-production', // YOUR_BUCKET_SLUG | |
read_key: '49TG2OEZMVML9fNvVObbFOEsjkFaCYpbVIP1kb8kYCY6RMWqBf' // YOUR_BUCKET_READ_KEY | |
}) | |
const app = async () => { | |
const data = await bucket.getObjects({ | |
query: { | |
type: 'products', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
const api = require('cosmicjs')() // empty init | |
const bucket = api.bucket({ | |
slug: 'docs-ecommerce-app-production', // YOUR_BUCKET_SLUG | |
read_key: '49TG2OEZMVML9fNvVObbFOEsjkFaCYpbVIP1kb8kYCY6RMWqBf' // YOUR_BUCKET_READ_KEY | |
}) | |
const app = async () => { | |
const data = await bucket.getObjects({ | |
query: { | |
type: 'products', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
const api = require('cosmicjs')() // empty init | |
const bucket = api.bucket({ | |
slug: 'docs-ecommerce-app-production', // YOUR_BUCKET_SLUG | |
read_key: '49TG2OEZMVML9fNvVObbFOEsjkFaCYpbVIP1kb8kYCY6RMWqBf' // YOUR_BUCKET_READ_KEY | |
}) | |
const app = async () => { | |
const data = await bucket.getObjects({ | |
query: { | |
type: 'products', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
const api = require('cosmicjs')() // empty init | |
const bucket = api.bucket({ | |
slug: 'simple-react-blog', // YOUR_BUCKET_SLUG | |
read_key: 'bucket-read-key' // YOUR_READ_KEY | |
}) | |
const app = async () => { | |
const data = await bucket.getObjects({ | |
query: { | |
slug: 'a-wonderful-blog-post-about-earth' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
const api = require('cosmicjs')() // empty init | |
const bucket = api.bucket({ | |
slug: 'simple-react-blog', // YOUR_BUCKET_SLUG | |
read_key: 'bucket-read-key' // YOUR_BUCKET_READ_KEY | |
}) | |
const app = async () => { | |
const data = await bucket.getObjects({ | |
query: { | |
type: 'posts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"created_at": 1632927978821, | |
"data": { | |
"_id": "61547f5e16bbc1ecc42e2bf6", | |
"order": 0, | |
"slug": "new-blog-post", | |
"title": "New Blog Post UPDATE", | |
"content": "<p>This is my blog post content...</p>", | |
"metafields": [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"created_at": 1632927654815, | |
"data": { | |
"slug": "new-blog-post", | |
"title": "New Blog Post UPDATE", | |
"metadata": { | |
"headline": "Amazing Beach!", | |
"image": { | |
"url": "https://cdn.cosmicjs.com/cc633600-2135-11ec-81a5-2b4858c629b3-quino-al-mBQIfKlvowM-unsplash.jpg", | |
"imgix_url": "https://imgix.cosmicjs.com/cc633600-2135-11ec-81a5-2b4858c629b3-quino-al-mBQIfKlvowM-unsplash.jpg" |
NewerOlder