Solved

NodeJs REST API for grant a promotional entitlement seems not work

  • 6 September 2022
  • 1 reply
  • 36 views

Badge

Hi: 

I’m trying to use the example exposed on the documentation:

const sdk = require('api')('@revenuecat/v4.0#1yz2c0m2sl5v5md8q');


sdk.auth('Bearer REVENUECAT_API_KEY');
sdk.grantAPromotionalEntitlement({duration: 'weekly'}, {
app_user_id: 'app_user_id',
entitlement_identifier: 'entitlement_identifier'
}).then(res => console.log(res))
.catch(err => console.error(err));

UnhandledPromiseRejectionWarning: Error: Sorry, `grantAPromotionalEntitlement` does not appear to be a valid operation on this API.

at Proxy.<anonymous> (/path/to/index.js)

at processTicksAndRejections (internal/process/task_queues.js:95:5)

 

But I can’t do it. 

Please, someone that could give me a way to keep going.

icon

Best answer by Jens 22 September 2022, 10:35

View original

1 reply

Userlevel 4
Badge +7

Hi @Jesus, for some reason, something broke about the generation of the NodeJS wrapper using the `api` library, and we haven’t been able to fix it. 

As an alternative, you can use the OpenAPI spec directly with the `api` library like this:

// Instead of this

const sdk = require('api')('@revenuecat/v4.0#1uypz42l7uldb2n');

// do this

const sdk = require('api')('https://docs-origin.revenuecat.com/openapi/61e6d1c8dc645600539687c6');

Let me know if this works!

Reply