monday.storage
is documented here: https://github.com/mondaycom/monday-sdk-js#mondaystorage
Attempting to save a key with name xxx.yyy.zzz
failed because keys can only be alphanumeric with the following aditional characters :_-
. This does not appear to be documented, but at least fails with a descriptive error message.
Without a newline character, everything is fine.
const monday = mondaySdk();
const someKey = "someKey";
const someVal = "Lorem Ipsum 123";
monday.storage.instance.setItem(someKey, someVal).then((res) => {
console.log(res);
// --> {method: 'storage', type: undefined, data: {success: true, version: 'edc92'}, requestId: 'en3u9u96f', errorMessage: undefined}
monday.storage.instance.getItem(someKey).then((res) => {
console.log(res.data.value);
// --> Lorem Ipsum 123
});
});
This now fails because of a new line character.
const monday = mondaySdk();
const someKey = "someKey";
const someVal = "Lorem Ipsum 123\n\nxxxx";
monday.storage.instance.setItem(someKey, someVal).then((res) => {
console.log(res);
// --> {method: 'storage', type: undefined, data: {success: true, version: 'edc92'}, requestId: 'en3u9u96f', errorMessage: undefined}
monday.storage.instance.getItem(someKey).then((res) => {
console.log(res.data.value); // --> NULL
});
});
Dodgy workaround to get around the failure from the new line character
const monday = mondaySdk();
const someKey = "someKey";
const someVal = "Lorem Ipsum 123\n\nxxxx";
const newLine = "[NEWLINE]";
monday.storage.instance.setItem(
someKey,
someVal.replaceAll("\n", newLine)
).then((res) => {
console.log(res);
// --> {method: 'storage', type: undefined, data: {success: true, version: 'edc92'}, requestId: 'en3u9u96f', errorMessage: undefined}
monday.storage.instance.getItem(someKey).then((res) => {
console.log(
res.data.value
); // --> Lorem Ipsum 123[NEWLINE][NEWLINE]xxxx
console.log(
res.data.value
.replaceAll(newLine, "\n")
); // --> Lorem Ipsum 123\n\nxxxx
});
});