I have a numeric field in a model set to have two decimal places, when I write a value such as 10.50
the CMS saves it accordingly in the latest version of Strapi, but my API endpoint removes the trailing 0 from the end so it comes out as 10.5
, which for a price isn’t ideal. Any solution to that without having to add logic on the front-end to add a 0 on the end?
Hi @josh Strapi in this case is returning the response from the database, so in this case I believe it’s your database that is trimming the trailing zero. I don’t believe there is a “Strapi side” modification that can be done easily to add that back in, it may be best to handle this on the frontend to “format” the data as currency. For example Javascript already has a built in function for this: Intl.NumberFormat - JavaScript | MDN
2 Likes
Thanks so much for the info and suggestion, that sounds like a nice solution! Shall look into implementing that.