Skip to content

Instantly share code, notes, and snippets.

@ivankisyov
Created January 30, 2019 08:20
Show Gist options
  • Save ivankisyov/1a39de00e275b0d3d2be7a401436b1e3 to your computer and use it in GitHub Desktop.
Save ivankisyov/1a39de00e275b0d3d2be7a401436b1e3 to your computer and use it in GitHub Desktop.
Faking a server using Nock
// npm install those first
const nock = require("nock");
const axios = require("axios");
nock("http://www.example.com")
.post("/items")
.reply(201, "user created");
axios
.post("http://www.example.com/items", {
name: "smith",
id: 11
})
.then(result => {
console.log("result>>>", result);
})
.catch(err => {
console.log("err>>>", err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment