Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // Remember to add npm dependencies (click the 🔧)
  2. const SanityClient = require('@sanity/client');
  3. const client = token => SanityClient({
  4. projectId: '<YouProjectId>',
  5. dataset: 'production',
  6. useCdn: false,
  7. token
  8. });
  9.  
  10. module.exports = async function(context, cb) {
  11. const { created } = context.body.ids;
  12. // Remember to add the token to secrets (click the 🔧)
  13. const { SANITY_TOKEN } = context.secrets;
  14. const res = await created.reduce((trans, _id) => trans.patch(_id).setIfMissing({
  15. title: 'Missing TITLE!!!'
  16. }), client(SANITY_TOKEN).transaction()).commit().catch(console.error)
  17. console.log(res)
  18. await cb(null, 200)
  19. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement