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));
        }
      });
    });

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

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.