Mock Server State

Mock Server State(DB)

Sometimes we might requrie to save data on mock server, and the data is shared and accessable by all mock api requests. This is fully supported by two programing interface( in “advanced request handling” mode:

mock api

Here is an example code block:

function HandleRequest(req, res, state) {

    var statecount = state.get("counter");

    if (statecount) {
        statecount.count  = statecount.count + 1;"counter", statecount);
    } else {
        statecount = {
            count: 1
        };"counter", statecount);

    res.send('hello, I am advanced Request handler:'+ statecount.count);

module.exports = HandleRequest