Create a frontend client for the API, allowing easy access to the API's models and custom routes.
import { createClient } from "squirrelify/client"; import { extensions, config} from "./api"; import { schema } from "./schema"; const client = createClient({schema, extensions, config}, { baseUrl: 'http://localhost:3000/', headers: { 'Authorization': 'Bearer 1234567890', } }); client.models.posts.get('abc-12').then(r => console.log(r)); client.custom('example-users').post({ age: 20, name: 'John Doe', email: 'john.doe@example.com', id: 'abc-123', created_at: new Date().toISOString(), updated_at: new Date().toISOString(), }).then(r => console.log(r)); Copy
import { createClient } from "squirrelify/client"; import { extensions, config} from "./api"; import { schema } from "./schema"; const client = createClient({schema, extensions, config}, { baseUrl: 'http://localhost:3000/', headers: { 'Authorization': 'Bearer 1234567890', } }); client.models.posts.get('abc-12').then(r => console.log(r)); client.custom('example-users').post({ age: 20, name: 'John Doe', email: 'john.doe@example.com', id: 'abc-123', created_at: new Date().toISOString(), updated_at: new Date().toISOString(), }).then(r => console.log(r));
Description
Create a frontend client for the API, allowing easy access to the API's models and custom routes.
Example