Angular HTTP Post date serialization format

Discussão em 'Angular' iniciado por Wouter Vandenputte, Janeiro 9, 2025.

  1. I have a JavaScript Date object that is a property of an object that I want to send with an HTTP Post request.

    But the problem is that it is serialized using my locale, whereas I need it to be serialized uniformly regardless of the client's locale.

    I know that, internally, the toJSON() is called and that I could overwrite the Date.prototype.toJSON method but this would overwrite it everywhere, whereas I only want it done for HTTP request bodies. Is this somehow configurable somewhere?

    Note: I absolutely do not want to manually serialize it. We have hundreds of post requests throughout the application, this should be default.

    Continue reading...

Compartilhe esta Página