Skip to main content

Monday Storage API "cannot read property 'instance' of undefined"

  • August 9, 2020
  • 8 replies
  • 2297 views

   static async getXP(token, userId) {
try {
  const mondayClient = initMondayClient();
  mondayClient.setToken(token);

  const response = await mondayClient.storage.instance.getItem('USER' + userId).then(res => {
    console.log(res.data.value);
    return res;
  }).catch(err => {
    console.log(err);
    return err;
  });

  return response;
} catch (err) {
  console.log(err);
}

}

I am getting an error stating that mondayClient.storage is undefined and so its property ‘instance’ cannot be read. I know mondayClient is defined because I can query the GraphQL API. I am trying to access the storage API from a Node js back end. Can the storage API only be accessed from the client or something, or am I just not seeing my mistake?

This topic has been closed for replies.

8 replies

basdebruin
  • Community Expert
  • August 9, 2020

Hi @hrustad1017

Welcome to the community. As far as I understand the .storage is indeed client side only (although I might be wrong here). I am using a SQL/MariaDB to store values.


  • Author
  • Participating Frequently
  • August 9, 2020

Thank you, I was thinking that was the issue.


  • Author
  • Participating Frequently
  • August 9, 2020

Is execute also client side only?


basdebruin
  • Community Expert
  • August 9, 2020

It is my understanding that only monday.api is available for server side apps (like the backend of an integration). Can somebody from monday.com please confirm or comment and if so change the documentation accordingly?


  • Author
  • Participating Frequently
  • August 9, 2020

I agree, or at least label which ones are server and which are client.

I just submitted a pull request with an update to the documentation. Not sure if my addition was styled the best, but it should at least get the ball rolling I hope.


  • Author
  • Participating Frequently
  • August 12, 2020

Apparently the README in the monday-sdk-js GitHub repository does say which capabilities are client side only, but it is easy to miss.


dipro
Forum|alt.badge.img
  • Leader
  • August 14, 2020

Hey folks! Sounds like you figured it out, but I just wanted to confirm:

  1. Yes, the storage API is only accessible from the client side
  2. The monday.API call can be used on the client- or server-side. If you use monday.api on the client side you will enjoy seamless authentication as well 🙂
  3. At the moment the only server-side method is monday.api, but watch this space!

  • Author
  • Participating Frequently
  • August 29, 2020

Could you add whether or not capabilities are available server side in the capabilities table of the monday-sdk-js readme on github? If you don’t work on that personally could you please get someone to do it?