Your question may require a bit more elaboration, but from the face of it I think this piece of code won’t lead to a succesful post to a node.js server. Unless localhost is running that server - but I guess this you may not have done and you are implicitly expecting?
Thanks for the reply, the localhost is running that server, and also the registration is completed but there is no response in the HTML page. And this console.log(“1 record inserted”); also works is just the res. send that doesn’t work. I think that I must be doing something wrong in the ts. file code but can’t figure out what. I get a message that says “Object object” on the HTML page.
If you see this in html, you may want to inspect the same value in console.log. As this means that the object you are trying to present needs better referencing - assuming it does have the data you need
The server is always the ultimate arbiter of what constitutes “correct” for a given request, but yes, “application/json” is a viable, proper content type, and, furthermore,
It is, and one should not be manually stringifying JSON or manually setting it as a content type. If you feed an object or a number as the body to an HttpClient request, the content type is automatically set to application/json. Similarly, it is set to application/x-www-form-urlencoded if you feed HttpParams, text/plain if you feed a string. The code that does this is here.