# 01 - Routes intro

In this module, we'll introduce the concept of routes.

## Routing Defined

Routing refers to determining how an application responds to a client request to a particular endpoint. An endpoint is a path and a specific HTTP request method attached to that path (GET, POST, DELETE, PUT).

## Overview

Here's a rough diagram of what's happening with our recent code that was used as a test in Postman:&#x20;

![screenshot](https://785407262-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAU8YfspjIVOP2BrMNl%2F-LAU8cHEwYbpO3Obye5i%2F-LAU8oLG19aithMKhU8w%2F01-router-endpoint-diagram.png?generation=1524162326578443\&alt=media)

## Analysis

1. A GET request is made to localhost:3000/api/test.
2. When the route is requested, Express finds the method for the specific route. The method that we already added for testing Postman is below:

   ```javascript
   app.use('/api/test', function(req, res){
    res.send("This is data from the /api/test endpoint. It's from the server.");
   });
   ```
3. So when we go to the `/api/test/` endpoint, we fire off an Express function `res.send`.
4. `res` (short for `response`) handles packaging up the response object.
5. The `.send()` method does the job of sending off the response.


---

# Agent Instructions: 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:

```
GET https://eleven-fifty-academy.gitbook.io/javascript-152-nodeserver/js_library/node-server/03-routes-intro/01-routes-intro.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
