Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/ApiManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class ApiManager {

callApi(
path: string,
method: 'GET' | 'POST' /*| 'POST_DATA' Not used */,
method: 'GET' | 'POST' | 'PATCH' /*| 'POST_DATA' Not used */,
data: any
) {
const http = this.http
Expand Down
21 changes: 19 additions & 2 deletions src/api/HttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class HttpClient {
readonly GET = 'GET'
readonly POST = 'POST'
readonly POST_DATA = 'POST_DATA'
readonly PATCH = 'PATCH'
isDestroyed = false

constructor(
Expand Down Expand Up @@ -47,7 +48,7 @@ export default class HttpClient {
}

fetch(
method: 'GET' | 'POST' | 'POST_DATA',
method: 'GET' | 'POST' | 'POST_DATA' | 'PATCH',
endpoint: string,
variables: any
) {
Expand Down Expand Up @@ -123,7 +124,7 @@ export default class HttpClient {
}

fetchInternal(
method: 'GET' | 'POST' | 'POST_DATA',
method: 'GET' | 'POST' | 'POST_DATA' | 'PATCH',
endpoint: string,
variables: any
) {
Expand All @@ -135,6 +136,10 @@ export default class HttpClient {
return this.postReq(endpoint, variables, method)
}

if (method === this.PATCH) {
return this.patchReq(endpoint, variables)
}

throw new Error('Unknown method: ' + method)
}

Expand Down Expand Up @@ -175,4 +180,16 @@ export default class HttpClient {
return data
})
}

patchReq(endpoint: string, variables: any) {
const self = this

return Request.patch(this.baseUrl + endpoint, {
headers: self.createHeaders(),
body: variables,
json: true
}).then(function (data) {
return data
})
}
}
2 changes: 1 addition & 1 deletion src/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const CANCEL_STRING = '-- CANCEL --'
const SETUP_PORT = 3000
const MIN_CHARS_FOR_PASSWORD = 8
const BASE_API_PATH = '/api/v2'
const API_METHODS = ['GET', 'POST']
const API_METHODS = ['GET', 'POST', 'PATCH']

export default {
ADMIN_DOMAIN,
Expand Down