Skip to content

Instantly share code, notes, and snippets.

@Daij-Djan
Created October 3, 2019 00:07
Show Gist options
  • Save Daij-Djan/0846d57923a0c2d20784c84f2f1105d9 to your computer and use it in GitHub Desktop.
Save Daij-Djan/0846d57923a0c2d20784c84f2f1105d9 to your computer and use it in GitHub Desktop.
simple mock HTTP server in node (using mock-http-server npm package)
var ServerMock = require("mock-http-server");
// Run an HTTP server on localhost:9000
var server = new ServerMock({ host: "localhost", port: 9000 });
server.start(Function());
server.on({
method: '*',
path: '*',
reply: {
status: 200,
headers: { "content-type": "application/json" },
body: JSON.stringify({ hello: "world" })
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment