DEV Community

Cover image for Quickly and easily mock a REST API with Restapify

Quickly and easily mock a REST API with Restapify

johannchopin on March 09, 2021

Hey devs 👋 Often when you start developing a new frontend project that consume a REST API, the backend is not yet ready. However, very often this ...
Collapse
 
flippingflapping profile image
flippingflapping

Great library, very simple and quick to use, thanks!

Is it possible to inject my own fake data across multiple fields in an array of objects? I see I can use the for-loop's array sequence and can inject each array value, but is it limited to iterating over an array of strings? Say, could I iterate over an array of objects so that I can use each prop and inject multiple values per iteration?

Collapse
 
johannchopin profile image
johannchopin

You are welcome thanks a lot for your comment 👍

So sadly there is no actual way to achieve such a thing with the for loop syntax 😥 However if you are motivated to help I could suggest you to open an issue and add some idea of implementation. It's not there yet but we can build it 💪

Collapse
 
michelemauro profile image
michelemauro

Isn't the "*" a problematic char to have in a filename?
do you think that would "_" be a good alternative?

Collapse
 
johannchopin profile image
johannchopin

Ah damn you are right it's not valid for the windows OS (and not really recommended for other OS ). Yeah I would fix that by using _ instead thanks for the hint 👍

Collapse
 
johannchopin profile image
johannchopin

Version 1.0.0 of restapify fix this issue by replacing the star selector with the underscore one 🚀 Thanks again for your comment 👍

Collapse
 
vasilyshelkov profile image
Vasily Shelkov

nice one on creating open source :) thanks for creating a post as well on it.

I know it's not quite the same, but I have found MSW (github.com/mswjs/msw) useful for mocking services on the frontend. I'm pointing it out in case there might be something useful that your project could use from it.

Collapse
 
johannchopin profile image
johannchopin

No problem thanks for the support. I never used this tool but it sadly still belong to the list of mocker where you have to write js code for each endpoints. It's really nice when you want to have the closest feeling to a real API but cost more time to build.

Collapse
 
leandroiwai profile image
leandroiwai

This is brilliant. It fit like a glove to the project I'm working now.

Collapse
 
johannchopin profile image
johannchopin

Thanks a lot 😊 Can't wait to have some feedbacks about it from other projects 💪

Collapse
 
saheb24027824 profile image
Uifoxes

JSON in very important for REST apis and name time we have to prepare the json for POST, PUT call in such case you can use this tool it will make your life easy onlinejsontool.com/json-editor

Collapse
 
johannchopin profile image
johannchopin

Nice tool but please stop spamming massive posts with the same comment 🙂