Create a GET endpoint
Build an HTTP endpoint that reads a query argument and answers with JSON.
On this page
This endpoint answers GET /api/hello/. It greets the name you pass in the address, or the world when there is none.

You need the Route, Code and Response components. See Download components.
Build it
- Drag Route, Code and Response onto the canvas.
- Connect Request of Route to Input of Code, and Output of Code to Response of Response.
- Double-click Route. Keep Method
GET, set Relative URL address to/api/hello/and select APPLY. - Double-click Code, replace the code with the code below and select APPLY.
- Double-click Response, empty Path for reading value and select APPLY.
- Select APPLY in the toolbar, then Continue.
The code of the Code node:
send({ message: 'Hello, ' + (value.query.name || 'world') + '!' });value is the request that Route sends: with Send to output set to Everything, the query arguments are in value.query.
Try it
curl 'http://localhost:8000/api/hello/?name=Jane'{"message":"Hello, Jane!"}Without a name:
curl http://localhost:8000/api/hello/{"message":"Hello, world!"}Why empty the path
By default, Response sends only the response property of the data it receives. Empty Path for reading value to send the whole object, or send your data inside response, as in Create a POST endpoint.