Running into an issue trying to update an item to the cms, I’m call on this function from with a loop, and updateItem
is the object from the loop.
const putToPlasmic = async (updateItem) => {
const CMS_ID = process.env.CMS_ID;
const CMS_SECRET_TOKEN = process.env.CMS_SECRET_TOKEN;
// console.log('updateItem :>> ', updateItem);
const rowId = "menuItem";
// Update entry, you can add `?publish=1` to the URL to automatically publish the updated row
const response = await fetch(
`<https://studio.plasmic.app/api/v1/cms/rows/${rowId}>`,
{
method: "PUT",
headers: {
// Your CMS ID and CMS Secret API token
"x-plasmic-api-cms-tokens": `${CMS_ID}:${CMS_SECRET_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify(updateItem),
}
);
console.log(`response: ${response}`)
};
and getting this response in my console.
Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: Gunzip {
_writeState: [Uint32Array],
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 5,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
bytesWritten: 0,
_handle: [Zlib],
_outBuffer: <Buffer 7b 22 65 72 72 6f 72 22 3a 7b 22 6e 61 6d 65 22 3a 22 4e 6f 74 46 6f 75 6e 64 45 72 72 6f 72 22 2c 22 73 74 61 74 75 73 43 6f 64 65 22 3a 34 30 34 2c ... 16334 more bytes>,
_outOffset: 0,
_chunkSize: 16384,
_defaultFlushFlag: 2,
_finishFlushFlag: 2,
_defaultFullFlushFlag: 3,
_info: undefined,
_maxOutputLength: 4294967296,
_level: -1,
_strategy: 0,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null,
[Symbol(kError)]: null
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: '<https://studio.plasmic.app/api/v1/cms/rows/menuItem>',
status: 404,
statusText: 'Not Found',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}