This is from the quickstart back end for the React Native quickstart app. Any chance I can get a hand updating this code block so that it uses json-bigint? I am getting errors in Heroku and the ios Simulator when trying to createCustomerCard in the React Native app.
app.post('/createCustomerCard', async (request, response) => {
const requestBody = request.body;
console.log(requestBody);
try {
const createCustomerCardRequestBody = {
cardNonce: requestBody.nonce
};
const customerCardResponse = await
customersApi.createCustomerCard(requestBody.customer_id,
createCustomerCardRequestBody);
console.log(customerCardResponse.result.card);
response.status(200).json(createPaymentResponse.result.payment);
} catch (e) {
console.log(
`[Error] Status:${e.statusCode}, Messages: ${JSON.stringify(e.errors, null, 2)}`);
sendErrorMessage(e.errors, response);
}
});
Errors:
ios simulator
Heroku logs:
2021-03-20T23:38:33.851157+00:00 app[web.1]: >
[email protected] start /app
2021-03-20T23:38:33.851158+00:00 app[web.1]: > node index.js
2021-03-20T23:38:33.851158+00:00 app[web.1]:
2021-03-20T23:38:34.734870+00:00 app[web.1]: Your app is listening on port 44636
2021-03-20T23:38:35.361890+00:00 heroku[web.1]: State changed from starting to up
2021-03-20T23:38:37.514978+00:00 app[web.1]: {
2021-03-20T23:38:37.514988+00:00 app[web.1]: customer_id: ‘JGS8WH3PPRT3D808FX977HZEM4’,
2021-03-20T23:38:37.514988+00:00 app[web.1]: nonce: ‘cnon:CBASELnSUOpJRGgvNRDOhLxHsKU’
2021-03-20T23:38:37.514988+00:00 app[web.1]: }
2021-03-20T23:38:38.125447+00:00 app[web.1]: {
2021-03-20T23:38:38.125460+00:00 app[web.1]: id: ‘ccof:sEVnVwiGTsVP1w3j3GB’,
2021-03-20T23:38:38.125490+00:00 app[web.1]: cardBrand: ‘VISA’,
2021-03-20T23:38:38.125493+00:00 app[web.1]: last4: ‘1111’,
2021-03-20T23:38:38.125494+00:00 app[web.1]: expMonth: 2n,
2021-03-20T23:38:38.125495+00:00 app[web.1]: expYear: 2038n
2021-03-20T23:38:38.125495+00:00 app[web.1]: }
2021-03-20T23:38:38.126389+00:00 app[web.1]: [Error] Status:TypeError: Do not know how to serialize a BigInt, Messages: undefined
2021-03-20T23:38:38.128560+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘0’ of undefined
2021-03-20T23:38:38.128561+00:00 app[web.1]: at sendErrorMessage (/app/index.js:117:17)
2021-03-20T23:38:38.128562+00:00 app[web.1]: at /app/index.js:93:5
2021-03-20T23:38:38.128563+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:93:5)
2021-03-20T23:38:38.128563+00:00 app[web.1]: (Use
node --trace-warnings ...
to show where the warning was created)
2021-03-20T23:38:38.130003+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict
(see
Command-line options | Node.js v15.12.0 Documentation). (rejection id: 1)
2021-03-20T23:38:38.130157+00:00 app[web.1]: (node:23) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2021-03-20T23:39:07.416018+00:00 heroku[router]: at=error code=H12 desc=“Request timeout” method=POST path="/createCustomerCard"
host=shenanigans-app-server.herokuapp.com request_id=d3063c57-3656-4f3b-9c10-4da5caa0bf68 fwd=“76.121.9.110” dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
I found this post because I was looking at “[Error] Status:TypeError: Do not know how to serialize a BigInt”
Anyway, this has been a blocker for me for a couple weeks so any help would be greatly appreciated!