Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Remember to add npm dependencies (click the 🔧)
- const SanityClient = require('@sanity/client');
- const client = token => SanityClient({
- projectId: '<YouProjectId>',
- dataset: 'production',
- useCdn: false,
- token
- });
- module.exports = async function(context, cb) {
- const { created } = context.body.ids;
- // Remember to add the token to secrets (click the 🔧)
- const { SANITY_TOKEN } = context.secrets;
- const res = await created.reduce((trans, _id) => trans.patch(_id).setIfMissing({
- title: 'Missing TITLE!!!'
- }), client(SANITY_TOKEN).transaction()).commit().catch(console.error)
- console.log(res)
- await cb(null, 200)
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement