Node.js HTTP Post (using AXIOS)
JS
S
JavaScriptThe simplest way to perform an HTTP request using Node is to use the Axios library (high abstraction level).
1const axios = require('axios')
2
3const payload = {
4 sample: 11
5};
6
7axios.post('https://coderecipes.org/telemetry', payload)
8.then((res) => {
9 console.log(`statusCode: ${res.statusCode}`)
10 console.log(res)
11})
12.catch((error) => {
13 console.error(error)
14})Created on 11/10/2018