API
Build a REST API with Hono, handle routes and path parameters, and connect to a Turso database
Introduction
A web server can be configured as a resource server accessed through a set of “external” functions or endpoints (API).
REST is a fairly common way of interacting between client applications and services using HTTP.
An HTTP request consists of a method and a “path”.
By default, browsers use the GET method, and when you navigate to a website you do so with a GET request and only need to specify the “path”.
But a web API uses other methods, and clients use these methods to perform actions other than obtaining resources.
Work Environment
Create an application (with the netlify template) as explained at HTML page.
Modify the index.ts file to return a JSON document at the path /api/hello.
'/api/hello', return ok: true,
message: 'Hello Hono!',
})
})Run the server in development mode:
Install curlie:
Make a GET request:
You're reading a preview.
Sign in to read the full article. Any account opens 10 free articles a month; students and teachers read their course pages without limit.
Sign in