DEV Community

Abdellah Sabiri
Abdellah Sabiri

Posted on

[fetchjson] Effortless Rest Api Mockup for your frontend/mobile app

I made a little webapp recently that may help frontend or mobile app people to accelerate their development with a mocked json Api.

The idea is to make your json schema and you get a unique url to get random generated data of your model.

For exemple i have a book listing app, my model would be like that:

{
   id,
   name,
   date,
   description,
   author:{
      name,
      bio
   }
}

So basicaly the model here is simple using the service:

{
   "id":"id",
   "name":"name",
   "date":"date",
   "description":"sentence",
   "author":{
      "name":"name",
      "bio":"sentence"
   }
}

Result:
https://fetchjson.com/api/public/5ea1a0bec99f05049b5123fa

This one will result as one element, if you want a list, obviously you will wrap it in an array:

[
   {
      "id":"id",
      "name":"name",
      "date":"date",
      "description":"sentence",
      "author":{
         "name":"name",
         "bio":"sentence"
      }
   }
]

Result:
https://fetchjson.com/api/public/5ea1a082c99f05049b5123f9

You can go for more complex combination of objects and array:

{
    "posts":[
        {
            "id":"id",
            "title":"sentence",
            "date":"date",
            "author":{
                "name":"name",
                "bio":"sentence"
            },
            "comments":[
                {
                    "id":"id",
                    "content":"paragraph",
                    "user":{
                        "id":"id",
                        "name":"name",
                        "avatar":"avatar"
                    }
                }
            ]
        }
    ]
}

Result of the generated data
https://fetchjson.com/api/public/5ea1a058c99f05049b5123f8

As you can see you define for each element its type, there are several types supported for the moment:

  • paragraph
  • sentence
  • number
  • image
  • avatar
  • name
  • address
  • email
  • id
  • date

You can try and generate you data now at : https://fetchjson.com

Top comments (1)

Collapse
 
devbirgit profile image
Birgit Pohl 🏑

I think a boolean could easily improve the app.