Save objects using storage API

Hi

I’m thinking about extensively using Monday storage API. I want to save objects. When I try to save objects with code below. I see the value is stored as a string like below

value: “[object Object]”

const obj = {
      "objList": [
        {
          "obj1": {
            "title": "obj1 title",
            "items": ["item1", "item2"]
          }
        }
      ]
    };

    monday.storage.instance.setItem('objs', obj).then(res => {
      console.log(res);
      monday.storage.instance.getItem('objs').then(res => {
        console.log('response of get item: ');
        console.log(res.data);
        if (res.data && res.data.value) {
          console.log(JSON.parse(res.data.value));
        }
      });
    });
  • So how can I store objects?
  • Should I set type option when I’m setting the object?
  • Is there any documentation about storage API? I cannot find anything except for https://github.com/mondaycom/monday-sdk-js#storage-api-mondaystorage
  • I need a database for my project. I will use it extensively. Should I search for a third-party database provider since storage API is not stable?

thank you

Hey @canbax - let me check in with the team on this.

-Daniel

Hey @canbax,

The “object object” error you are seeing is due to the API being sent a JS object. Currently our storage API supports numbers and strings, so you would need to serialize the object first (essentially stringify it before adding it to the storage).

In terms of documentation, at this time the GitHub link you posted is the existing documentation for the storage API, however we’re looking to improve this as we continue to improve our API and Apps.

-Daniel

Thank you for your very quick response, Daniel!

1 Like