DEV Community

Nikolay
Nikolay

Posted on • Updated on

Does front end developer need a mock API Service?

Hello.
My name is Nikolay.
I am a front web developer. I am currently participating in a small enterprise project.
There are two of us. Front end developer and Back end developer.

The thing is that sometimes we are working asynchronously, I mean, one day when I need to use some REST API it's not ready. Another day its done but contains not enough data and it will take some days to change it according to new requirements. On my practice that situation where several times in some projects.

The first solution came up to me, is to generate fake data on the client and simulate request to the server. The advantage of this is that it's up to you and you don't need anyone to fix this. The disadvantage is your project build contains the code with fake data and fake data generators go to your build to. And sometimes it's big.

As the second solution, I was looking for online mock API services. I found a few but no one did not match my requirements.

Wasn't thinking too long, I decided to create my own mock API service.

And of course with my tricky requirements:

  • Dynamic response generation via Mustache or another template engine,
  • Url matching support. For example: /getClient/:clientId
  • Custom media library. To provide links to real data files or images you want.
  • Work with teams on projects.
  • Request History

What do you thinking of that guys?
Is this all make sense or I am fighting with windmills?

P.S.
If you are interested in my service please take a look on the prototype on https://fake.rest

Top comments (2)

Collapse
 
patroza profile image
Patrick Roza

I like the idea, we’ve also been fighting with similar things. As alternative you can develop with local mock data in storybook and e.g exclude that from the prod build. Only when the api is fully ready, you can then finish the actual integration.

With storybook you need to mock props from your UI. With api mock you need to mock your api models. I guess in the end it comes down to which one is more stable in your project. But Storybook comes with a lot of other benefits too.

Collapse
 
znick1982 profile image
Nikolay • Edited

Hi Patrick.
Thanks for the proof that I am not only one with my problem.
I watched at the Storybook and I like it. I believe it could be complementary tools. For example in Storybook you can test your components separately and with Mock API you could test entire application and look how components work in conjunction.