cosmicjs / cosmic-sdk-js

The official JavaScript SDK for Cosmic. Use it to power content server-side, in the browser, and in native apps.
https://www.npmjs.com/package/@cosmicjs/sdk
MIT License
14 stars 2 forks source link

Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member. #18

Closed alfdocimo closed 1 year ago

alfdocimo commented 1 year ago

Hi there! 👋

Massive kudos on the new sdk! 🙌 Been using cosmicjs for a while now, and with new dashboard beta, I had to give the new sdk a shot!

I'm having a bit of trouble setting things up, seems like you cannot await on queries? 🤔

For instance:

async function main() {
  let posts = await cosmic.objects
    .find({
      type: 'posts',
    })
    .props(['title', 'slug', 'metadata'])
    .limit(10);

  return posts;
}

TS will complain with:

Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.(1320)

I've created a minimal stackblitz project to recreate this:

https://stackblitz.com/edit/node-goqgyn?file=src/index.ts

Again, kudos on the awesome work! 💯

tonyspiro commented 1 year ago

Thank you @alfdocimo! Apologies, this issue slipped past us. We'll review and let you know when we have an update. Thank you for the report 🙌🏻

tonyspiro commented 1 year ago

Closing this issue, as it's been addressed in #19 @alfdocimo to see this fix, upgrade to the latest version with npm i @cosmicjs/sdk@latest

alfdocimo commented 1 year ago

Cheers and kudos on the awesome work! 🚀