The output from the customers API in the online API explorer (https://developer.squareup.com/explorer/square/customers-api/list-customers#) includes a “version” key with a 64-bit integer value. (Reference doc here: GET /v2/customers - Square API Reference) However, when I call the API from my NodeJS/Express code, an “n” is appended to the value. For example, the online API explorer returns " version: 1 " regardless of the method I choose (cURL, Python, NodeJS, etc) but when I call it from my Node server it returns " version: 1n." The “n” makes the JSON.stringify() method believe it’s trying to serialize a big int value and returns an error. Please advise if this is intentional, or an error on my part, and/or a course of action forward. Thanks!
Here is a snippet of the API output from my server and the associated error message:
…
version: 2n
}
TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
Here is a snippet of my code for the Express route that calls the customers API:
app.get('/customers', async (req, res)=>{
const customersApi = client.customersApi;
try {
const response = await customersApi.listCustomers();
console.log(response.result.customers[0]);
res.send(JSON.stringify(response.result.customers[0].version))
} catch(error) {
console.log(error);
res.send('<h2>Error</h2>')
}