Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
Axios 0.21.3 Content-Type issue
node v14.20.1
version:
2.0.0
endpoint
share
tweet
This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
const http = require("http"), axios0_21_3 = require('axios@0.21.3'), axios0_21_1 = require('axios@0.21.1'); function doPOSTRequest(axios, version) { return axios({ method: 'post', url: 'http://127.0.0.1:8080', data: { my: 'object' } }) .then(res => console.log(`Content-Type with v${version}: ${res.data['content-type']}`)); } const server = http .createServer((req, res) => { res.write(JSON.stringify(req.headers)); res.end(); }) .listen(8080, async() => { await doPOSTRequest(axios0_21_1, '0.21.1'); await doPOSTRequest(axios0_21_3, '0.21.3'); server.close(); });
Loading…
no comments
sign in
to comment