DEV Community

Discussion on: I have a question about how to send data to websites

Collapse
 
pauladrian profile image
Paul

In my search I found out about what the first website should do, however how can I make the website "watch out" for POSTs sent by the first website? That's the part I can't find out what I need to learn to do. You advice that I should look into Node to do that? Thank you.

Collapse
 
rossangus profile image
Ross Angus • Edited

The method outlined by @juanfrank77 concerns the sending of the information via the POST method. Personally, I'd just use standard HTML for that task:

<form id="numberForm" method="post" action="https://your-second-website-url-goes-here.test/">
      <label for="numberInput">Enter a number:</label><br>
      <input type="number" id="numberInput" name="numberInput"><br>
      <input type="submit" value="Submit">
</form>
Enter fullscreen mode Exit fullscreen mode

... but that's just me.

In terms of receiving that data and processing it, some form of server-side language would be requited. JavaScript running in the browser is sandboxed so cannot do this, however, as @juanfrank77 points out, when JavaScript runs on the server (in the form of Node.js), then this becomes possible. Note that Node is just one of many languages which could do this, for example .NET, PHP. Perl, if you're feeling nostalgic...

This is probably overkill, but a framework such as Next.js (which encompasses JavaScript, Node and React) is one way to achieve this. But that's a lot to learn!