Skip to content

Instantly share code, notes, and snippets.

@achepukov
Last active March 18, 2019 10:13
Show Gist options
  • Save achepukov/d093bc06ab1b9c3984e4673d976d076f to your computer and use it in GitHub Desktop.
Save achepukov/d093bc06ab1b9c3984e4673d976d076f to your computer and use it in GitHub Desktop.
Call api wrapper
// @flow
export class ApiCall {
constructor(url: string) {
this.url = url;
}
get = (id?: string) => app.api.get(id ? `${this.url}/${id}` : this.url);
post = (body: object = {}) => app.api.post(body);
put = (body: object = {}) => app.api.put(body);
delete = (id?: string) => app.api.delete(`${this.url}/${id}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment