Skip to content

SDK Fails with "SdkError: Failed to parse JSON response" on non-200 responses #204

@ohana54

Description

@ohana54

Hi,

We noticed that sometimes the service returns 500/502 errors and the response body is html.
The code doesn't check the status code and tries to parse the body as json, which fails with the error "SdkError: Failed to parse JSON response".

Context:
https://github.com/fingerprintjs/fingerprintjs-pro-server-api-node-sdk/blob/0feaf6bfee8a9355ddd0b06feffb35e81238fe88/src/serverApiClient.ts#L86-L91

It would be nice to handle these cases so we can get a meaningful and correct error back.
I'll be happy to submit a PR if needed.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions