Skip to main content

Save objects using storage API

  • Oct 13, 2020 6:37 PM UTC
  • 4 replies
  • 2072 views

canbax

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

This topic has been closed for replies.

4 replies

dsilva
Forum|alt.badge.img
  • Participating Frequently
  • Oct 13, 2020 8:24 PM UTC

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

-Daniel


dsilva
Forum|alt.badge.img
  • Participating Frequently
  • Oct 13, 2020 9:40 PM UTC

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


canbax
  • Author
  • New Participant
  • Oct 14, 2020 11:43 AM UTC

Thank you for your very quick response, Daniel!


  • Mar 10, 2021 4:43 PM UTC

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