> For the complete documentation index, see [llms.txt](https://akhilgangula.gitbook.io/mock-json-response/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://akhilgangula.gitbook.io/mock-json-response/master.md).

# Getting started

## Installation

Mock JSON Response is distributed via node package manager and can be included in your project using package.json

To add the mock-json-response as a project dependency, create a project

```bash
$ mkdir backend-mock
$ cd backend-mock
```

Once the project is created, initialize npm

```bash
$ npm init
```

follow the instruction on the terminal and enter the necessary information, now it time to install mock-json-response

```bash
$ npm install mock-json-response
```

&#x20;after the package is loaded in your environment, create 2 new folders for data and functions.

```bash
$ mkdir functions
$ mkdir data
```

Its time to launch the app. Before we launch it we need to import module, create an index.js

{% code title="/backend-mock/index.js" %}

```javascript
const logicalDir = __dirname + '/functions';
const dataDir = __dirname + '/data';

require('mock-json-response')(logicalDir, dataDir);
```

{% endcode %}

Create a JS file in the functions directory: hello.js

{% code title="functions/hello.js" %}

```javascript
module.exports = {
    logic: function ({ headers }, { data }) {
        // logic for data manipulation comes here
    },
    request: {
        method: "GET",
        urlPath: "/mock/test"
    },
    response: {
        status: 200,
        inlineData: {
            message: 'Hello world'
        }
    },
};
```

{% endcode %}

Now start the program:

```bash
$ node index.js
```

and wait for the server to start up

```bash
Loading routes...
loaded hello.js
Server started
```

Now send a request via browser, postman or terminal to localhost:3000/mock/test

```bash
curl -X GET http://localhost:3000/mock/list
```

The default port of the server is 3000, once the route is hit, you will get the response

```javascript
{message:'Hello world'}
```

You have successfully, setup backend mock.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://akhilgangula.gitbook.io/mock-json-response/master.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
