Search code examples
javascriptnode.jsxmlhttprequest

How to get the payload content posted by an external website to my website with JS?


I am integrating an external website with mine and this website executes a POST request to add a xml file into my website. I have no control over how they do that, my part is just to receive this data and treat it as I need. But since it is the first time I am dealing with this situation and that I don't have experience with back end, I'm not sure if I can do that just using JS or if I should build some back end app to retrieve the data. I couldn't find a clear answer.

enter image description here

The request is being made and I can see the data in the payload section, but I don't know how to access it.

enter image description here

Am I missing something?


Solution

  • You cannot "post" data to a website from another website the way you envision it. What you need is a server that can receive a post-request and then process the XML. Your website then has to communicate with that server via fetch for example and retrieve that data. Or you could use a protocol such as WebSockets to push the data to your website once it's available to the server.