# Get answer

*By Sagarika and Sanket*

***

## **https\://{ngrok-link}/get\_response**

The API endpoint allows you to make an HTTP POST request to {**ngrok-link}**/get\_response in order to retrieve an **answer** based on the provided **query** and **sessionID**.

Note: **ngrok-link** referes to https\://[ngrok](https://ngrok.com/) link in the future.

### Request

The request should include a JSON payload with the following parameters:

* `query` (string): The user’s query.
* `sessionID` (integer): The 10-digit session ID associated with the query.

**Request Body Format (data)**

{% code title="json" %}

```json

{
"query": "example query",
"sessionID": 12334567890
}
```

{% endcode %}

{% hint style="info" %}
The **data** needs to be stringify.
{% endhint %}

### Response

Upon successful execution, the API will return a JSON response with the following structure:

* `answer` (string): The response to the provided query.
* `status` (string): The status of the response (“success” or “error”).

**Example Response Format**

{% code title="json" %}

```json
{
"answer": "example response",
"status": "success"
}
```

{% endcode %}

#### Response Status <a href="#response-status" id="response-status"></a>

* `200 OK`: The request was successful and the response is available.
* `404 Not Found`: The requested resource could not be found.

#### Response Content-Type <a href="#response-content-type" id="response-content-type"></a>

* `application/json`: The response content is in JSON format.&#x20;

***

### Example Request

{% code title="JavaScript - Fetch" overflow="wrap" fullWidth="true" %}

```javascript
const raw = "{\r\n    \"query\": \"I looking for a silent synergy leadership series\",\r\n    \"sessionID\": 1234512345\r\n}";

const requestOptions = {
  method: "POST",
  body: raw,
  redirect: "follow"
};

fetch("http://127.0.0.1:5010/get_response", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));
```

{% endcode %}

### Example Reponse

{% code title="json" overflow="wrap" fullWidth="true" %}

```json
{
    "answer": "It is filled with thoughts, plans and reactions to whatever is happening around us. And this continuous mental activity becomes a major bottleneck. When we are trying to find that internal silence, our minds tend to react very quickly to external stimuli. We are wired to respond to the demands of our environment. In leadership, this means that we are often in a state of constant reaction to the needs of our teams, to the changes in our organizations, to the shifts in the market.\n\nExplores the struggle of maintaining internal calm amidst leadership challenges.",
    "status": "success"
}           
```

{% endcode %}
