question

parveen.dubb avatar image
parveen.dubb asked

Getting error for countries list while running node.js sample project.

I am trying to run node.js sample project (https://developer.fusionfabric.cloud/extensions/ffdc-dev-portal-docs/public/sample-client-node.html) and getting error for countries list.

Error:

Sample app listening on port 5000!
{ FetchError: invalid json response body at https://api.fusionfabric.cloud/corporate/staticdata/v1/countries reason: Unexpected end of JSON input
at C:\git\ffdc\ffdc-sample-nodejs\node_modules\node-fetch\lib\index.js:272:32
at process._tickCallback (internal/process/next_tick.js:68:7)
message:
'invalid json response body at https://api.fusionfabric.cloud/corporate/staticdata/v1/countries reason: Unexpected end of JSON input',
type: 'invalid-json' }

10 |600

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Laurent Chollet avatar image
Laurent Chollet answered

The nodeJs sample implements the client credentials code flow and can be used with B2B APIs. The SpringBoot sample implements the authorization code grant flow and can be used with the other types of APIs (B2E and DIGITAL). We will add samples for:

  • NodeJS and authorization code grant flow
  • SpringBoot and client credential grant flow
10 |600

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Dawid Rampalski avatar image
Dawid Rampalski answered

Hello,

It appears you are using the Static Data API, which is DIGITAL, but reading the Referential Data API documentation, which is B2B (so you must be careful and use the right client id and secret).

10 |600

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

parveen.dubb avatar image
parveen.dubb answered

Thanks for your answers, But we have resolved this with the help of Felix Grevy. There were two issues, one is the URL in new documentation is not right and second one is keys format in the .env file is not right. Ending quotes need to be next line for the auth keys.

Working URL : https://api.fusionfabric.cloud/referential/v1/countries

CLIENT_ID="xxxxx-xxx-xxxx-xxx-xxxxxxxxxxx

"

CLIENT_SECRET="xxxxx-xxx-xxxx-xxx-xxxxxxxxxxx

"

Thanks

10 |600

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.