Easily integrate with API endpoints built with Phaster.
npm install phaster-api
import { Endpoint, request } from "phaster-api";
The request
function is a small wrapper around fetch
which automatically parses JSON responses.
The Endpoint
class simplifies requests to Phaster API endpoints:
const users = new Endpoint<User>("/api/users", request);
Each Endpoint
instance has the following methods:
Make a GET
request to search entities.
Return a single entity by ID.
Create multiple entities with a single request. Returns the saved entities with their ID.
Create a single entity. Returns the saved entity with its ID.
Replace all writable properties on a single entity.
Automatically call post
or put
depending on whether the entity has an ID, and return the saved entity with its ID.
Update a subset of properties on one or more entities (pass a comma-separated list of IDs to update multiple rows).
Delete one or more entities (pass a comma-separated list of IDs to delete multiple rows).