Skip to content

Commit

Permalink
feat(nile-js): add delete
Browse files Browse the repository at this point in the history
  • Loading branch information
jrea committed Mar 23, 2022
1 parent 1e8985a commit fd41d68
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions lib/nile/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ class Nile {
.fetch('POST', `${entity}/${String(id)}`, payload)
.then(convertToJSON);
}

/**
*
* @param entity @type {UpdatableEntities} maps to the urls in the api
* @param payload @type {unknown} the maps to the payload types TODO
* @returns {Promise<EntityType>} the deleted entity
*/
delete(entity: UpdatableEntities, payload: unknown): Promise<APIResponse> {
this.setRequesterAuth();
const { id } = payload as { id: string };
return this.requester
.fetch('DELETE', `${entity}/${String(id)}`)
.then(convertToJSON);
}
}

export default Nile;
2 changes: 1 addition & 1 deletion lib/nile/src/requester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class Requester {
* @returns @type {Promise<Response>}
*/
fetch(
method: 'POST' | 'GET',
method: 'POST' | 'GET' | 'DELETE',
entity: CreateableEntities | UpdatableEntityUrls | UpdatableEntities,
payload?: unknown
): Promise<Response> {
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/utilities/nile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Nile from '@nile/js';
import Nile from '@theniledev/nile-js';
const nile = new Nile({ apiUrl: 'http://localhost:8080' });

export default nile;

0 comments on commit fd41d68

Please sign in to comment.