Format prices obtained from cart.js API

Hello, I am developing an application that adds a button to the cart screen, once that button is clicked, through a javascript asset configured in my ThemeAppExtension I make a query to an endpoint in my Shopify App (Developed from the remix template) in this query I send what I get from the Fetch Api of the cart (cart.js) and then in my endpoint I perform a couple of operations on the cart. My problem is that what I get from cart.js comes in whole numbers and the decimals are completely lost therefore my operations are not correct. I have been reading that there is something called Shopify.formatMoney( price ) and that it is an asset that is imported through Liquid, the problem with this is that I do the operations in the endpoint of my Shopify app, how could I solve this?

You can use this code snippet to format prices:

https://gist.github.com/stewartknapman/8d8733ea58d2314c373e94114472d44c

I recently commented there with a TypeScript version that supports all currency formats.

Best,

Tobe

Hello @tobebuilds thanks for the anwser, do you have some example of use of this?