Fake Server for test Rest’s calls

Diego Gonçalves Santos
2 min readJun 5, 2017

--

Hello everyone! Today I am gonna talk about a very helpful tool that I came across when trying to finish validating my rest calls for the Sprint while the server wasn’t ready yet.

For these situations this “fake server” tool can be really handy and it is surprisingly easy to configure. As the description on the github repo https://github.com/typicode/json-server, you can get a server up and running in 30 seconds!

Just install the lib running the npm command from your terminal: “$ npm install -g json-server” and create a file db.json where you gotta write the expected json results like in this example bellow:

After that, just run the command "$ json-server — watch db.json" inside the folder where you have saved the json file. If the json is syntactically correct then you can just go to: http://localhost:3000/login for example and then you gotta get the above json as a result.

Note:

To use the fake server externally, to consume in an app for example, you can just replace in the url “localhost” with your machine’s ip and that gonna work if both the computer and the phone are in the same network.

Well that is it, hope it can be helpful for anyone! See you soon!

--

--

Diego Gonçalves Santos

Engenheiro de Software @Dextra_digital, escritor, palestrante, entusiasta de tecnologia e esportes.