Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Suppose I am an frontend engineer and I need a REST API which backend team is going to implement. I am waiting for that API to get implemented by backend team. Instead of waiting, one can just create the API Mock and use it in their workflow. Lets walk through step by step, how API Mock can be created.

Suppose I want to create the following API Mock:

API Endpoint/contact/{{contactId}} 
Method

GET

Response HeadersContent-Type: application/json
Response Body
{
  "_id": "{{contactId}}",
  "name": "John Doe",
  "email": "john.doe@example.com",
  "designation": "Chief Technical Officer",
  "organization": "Example.com",
  "country": "India",
  "aboutMe": "My name can be used as a placeholder name and I don't have any issue with that.",
  "twitterId": "fake.john.doe",
  "facebookId": "fake.john.doe",
  "githubId": "fake.john.doe",
  "createdOn": "2014-05-03T06:28:45.479Z"
}

Here contactId is a variable. Whatever is supplied in the URL for contactId variable should also be replaced in the response body.

...

We can create the above API Mock by following the steps below:

  1. First create an API Mock

    Image Added

  2. Setup response headers

     Image Added

  3. Setup response body

    Image Added 

  4. Verify that the Mock is working now

    Image Added