# rest **Repository Path**: iamfat/rest ## Basic Information - **Project Name**: rest - **Description**: @genee/rest - **Primary Language**: TypeScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-02-09 - **Last Updated**: 2022-02-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # @genee/rest ## Usage ```typescript import REST from '@genee/rest'; type UserData = { id: number; name: string; }; class UserService extends REST { private token: string; construct() { super('https://host/base/url/api'); } // will be called only once before the very first request protected async init() { // you have to use rawRequest this.token = await this.rawRequest(this.url('v1/token')); } // pass inited token to headers in each request protected get additionalHeaders() { return { Authorization: `Bearer ${this.token}`; } } // or pass inited token to queries in each request protected get additionalQueries() { return { token: this.token; } } } (async () => { const gateway = new REST('https://host/base/url/api'); const user = await gateway.post('v1/user', { name: 'Doe John' }); })(); ```