👀 See Sanity in action: Watch product demo now →

How to set the Slug to the orderId using the Sanity Client with an API Request

3 replies
Last updated: Aug 5, 2022
Hi, I’m having another small issue trying to update a slug on a id…not sure I’ve got the settings right to update the slug. I’m using the sanity client with an api request
export const updateOrderDetailsSuccess = async (
) => {
  await newSanityClient
      status: "Authorized",
      slug: {
        _name: orderId,
        _type: "slug",
Aug 5, 2022, 6:25 PM
If I'm understanding correctly and you want to set the slug to the orderId, you'd want to do something like this:
slug: {
  _type: 'slug',
  current: orderId
Aug 5, 2022, 6:29 PM
Perfect, worked a charm!
Aug 5, 2022, 6:30 PM
Aug 5, 2022, 6:31 PM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.