Mockbin Node.js Example

node v8.17.0
version: 1.0.0
endpointsharetweet
Mocking Node.js Example
var http = require("http"); var options = { "method": "POST", "hostname": "mockbin.com", "port": null, "path": "/request?foo=bar&foo=baz", "headers": { "cookie": "foo=bar; bar=baz", "accept": "application/json", "content-type": "application/json", "x-pretty-print": "2" } }; var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.write(JSON.stringify({ foo: 'bar' })); req.end();
Loading…

no comments

    sign in to comment