Skip to content

TypeError: fetch failed / 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH' #55410

Closed Answered by bushidavid
bushidavid asked this question in Help
Discussion options

You must be logged in to vote

Issue was related to the API returning a BigInt. Implemented a function that takes the result of the API with the BigInd id, and transforms any BigInt value into a string.

const countries = data.map((country) => {
            const transformBigIntToString = (key, value) => {
              return typeof value === 'bigint' 
                ? value.toString() 
                : value;
            };
          
            // Use JSON.parse and JSON.stringify to apply the transformation
            return JSON.parse(JSON.stringify(country, transformBigIntToString));
          })

API now works from Postman and return correct result.

Replies: 6 comments 11 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@bushidavid
Comment options

@icyJoseph
Comment options

@bushidavid
Comment options

@icyJoseph
Comment options

@bushidavid
Comment options

Comment options

You must be logged in to vote
1 reply
@icyJoseph
Comment options

Answer selected by bushidavid
Comment options

You must be logged in to vote
1 reply
@freeversity
Comment options

Comment options

You must be logged in to vote
1 reply
@juan-carlos-correa
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
7 participants