Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixBigInt transforms some GET request res.bodys to string. #293

Open
iritmaximus opened this issue Sep 27, 2024 · 2 comments
Open

fixBigInt transforms some GET request res.bodys to string. #293

iritmaximus opened this issue Sep 27, 2024 · 2 comments

Comments

@iritmaximus
Copy link
Collaborator

export const fixBigInt = (obj: object | null) =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
obj === null ? null : JSON.stringify(obj, (_key, value) => (typeof value === 'bigint' ? Number(value) : value))
It seems there is no particular need to implement fixBigInt this way.

In fact, few services that utilize the fixBigInt parse the returned string back to object.

return JSON.parse(fixBigInt({ ...result, com_taxa_synonym: synonyms || [] })!) as SpeciesDetailsType

@iritmaximus iritmaximus changed the title fixBigInt transforms all GET request res.bodys to string. fixBigInt transforms some GET request res.bodys to string. Sep 27, 2024
@iritmaximus
Copy link
Collaborator Author

Also this transformation is made for only some paths:

return res.status(200).send(fixBigInt(species))

but not
return res.status(200).send(species)

@ShootingStar91
Copy link
Contributor

Indeed, best to do it in one level, I probably meant to refactor it into services but forgot some of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants