Skip to content

Commit

Permalink
Add check for status
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin SAURAYE authored and bonjourmauko committed Nov 28, 2023
1 parent de154b3 commit 212dd99
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ interface DiscussionSubject {
"id": string
}

export type { Theme, Subtheme, DiscussionRequest }
interface DiscussionResponse {
status: 200
data: DiscussionRequest
}

export type { Theme, Subtheme, DiscussionResponse }
12 changes: 12 additions & 0 deletions src/services/api/resources/DiscussionsAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ export default class DiscussionsAPI extends DatagouvfrAPI {
return await this.makeRequestAndHandleResponse(url)
}

/**
* Base function for HTTP calls (without error handling)
*
* @param {string} url
* @param {string} method
* @param {object} params
* @returns {Promise}
*/
async _request(url, method = 'get', params = {}) {
return await this.httpClient[method](url, params)
}

/**
* Create an discussion (POST)
*
Expand Down

0 comments on commit 212dd99

Please sign in to comment.