Response

Control how to respond to a request

Mock JSON Response helps control every aspect of a response by providing the following attributes

  1. status

  2. headers

  3. inlineData

  4. bodyFileName

Here is an example:

{
    status: 200,  //status of response
    headers: {    //headers in response
        "Content-Type": "application/json",
    },
    inlineData: {   //a way to pass raw data
        test: 'inline data'
    },
    bodyFileName: "data.json"   //name of the file with raw json data
}

if the status is not defined, 200 is sent by default.

Status

status code of the response to be sent.

Headers

Headers to be set in the response.

Inline Data

Its a JS object which holds the data to be sent in the response.

Body File Name

This is a string which will define the name of the JSON file that will be used to import the response.

inlineData takes precedence on bodyFIleName

Other attributes of the response object will be discussed in upcoming chapters.

Last updated