A Node.js module that provides a typesafe wrapper class around the fetch api that is easily extendable ## Installation ```sh npm install definitely-typed-fetch-api --save yarn add definitely-typed-fetch-api bower install definitely-typed-fetch-api --save
npm install definitely-typed-fetch-apish
npm install definitely-typed-fetch-api --save
yarn add definitely-typed-fetch-api
bower install definitely-typed-fetch-api --save
`
Usage
$3
`typescript
import BaseService from './BaseService';
import { SmoothieOrderResponse, SmoothieOrder } from './smoothieServiceTypes';class SmoothieService extends BaseService {
constructor() {
super('www.smoothiecentral.com');
}
public async getSmoothieOrders(): Promise {
return await this.get(
${this.getServiceContext()}/smoothie/orders);
} public async createNewSmoothieOrder(order: SmoothieOrder): Promise {
return await this.post(
${this.getServiceContext()}/smoothie/createorder, order);
} public async modifySmoothieOrder(order: SmoothieOrderResponse): Promise {
return await this.update(
${this.getServiceContext()}/smoothie/createorder, order);
} public async deleteSmoothieOrder(orderId: string): Promise {
return await this.delete(
${this.getServiceContext()}/smoothie/deleteorder/${orderId});
} protected testResponse(): Promise {
return new Promise((resolve, reject) => resolve({
orderNumber: 1,
smoothieOrders: [
{
fruit: 'apple',
blendStyle: 'chunky',
size: 'medium',
},
{
fruit: 'apple',
blendStyle: 'chunky',
size: 'medium',
}
]
}));
}
}
export default SmoothieService;
`
Test
`sh
npm run test
``