Monday, 13 March 2017

How to process POSTed data with JS?

I've successfully sent a hello world string to my website, but I don't know how to handle that data using JS on my website, and then display it in an HTML element. Please help me. My Node.js code for sending the data is:

const request = require('request-promise');
const body = {
server_count: 'hello world'
};

    return request({
    method: 'POST',
    url: 'http://mywebsite.com',
    body: body,
    json: true
}).then(() => {
    console.log(`Sent data to site!`);
}).catch(err => {
console.log('Error sending data to site:', err);
});

Thanks in advance.



via Gavwin

No comments:

Post a Comment