diff --git a/src/api/response.js b/src/api/response.js index 7a17982..b709f7f 100644 --- a/src/api/response.js +++ b/src/api/response.js @@ -14,18 +14,34 @@ class Response { this.#success = success } + /** + * Get the response data + * @returns {*} + */ get data() { return this.response } + /** + * Parse the response as JSON + * @returns {Promise<*>} + */ async json() { return await this.response.json() } + /** + * Has the request failed? + * @returns {boolean} + */ get failed() { return this.#success === false } + /** + * Has the request succeeded? + * @returns {boolean} + */ get succeeded() { return this.#success === true }