Your API in three steps
You only have to create a table, insert data using SQLite, and define the schema of your API.
Create a table
CREATE TABLE IF NOT EXISTS friend ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT );
Add some data
INSERT INTO friend (name) VALUES ('Jennifer'); INSERT INTO friend (name) VALUES ('Courteney'); INSERT INTO friend (name) VALUES ('Lisa');
Define an API
api: service: web-app query: SELECT * FROM friend LIMIT COALESCE(@limit, 10) method: GET path: /friend headers: { Access-Control-Allow-Origin: '*', Access-Control-Allow-Methods: 'GET', Cache-Control: 'max-age=3600', }
Enjoy it ;)
fetch('https://odb.dev/api/friend?limit=2', {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
}
});