Merge pull request #2498 from mslourens/add_patch_to_rest_api

add patch method to the rest api interface
This commit is contained in:
Martin McKeaveney 2021-08-31 13:14:10 +01:00 committed by GitHub
commit 743753da3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 0 deletions

View File

@ -89,6 +89,26 @@ module RestModule {
}, },
}, },
}, },
patch: {
displayName: "PATCH",
readable: true,
type: QueryTypes.FIELDS,
urlDisplay: true,
fields: {
path: {
type: DatasourceFieldTypes.STRING,
},
queryString: {
type: DatasourceFieldTypes.STRING,
},
headers: {
type: DatasourceFieldTypes.OBJECT,
},
requestBody: {
type: DatasourceFieldTypes.JSON,
},
},
},
delete: { delete: {
displayName: "DELETE", displayName: "DELETE",
type: QueryTypes.FIELDS, type: QueryTypes.FIELDS,
@ -175,6 +195,21 @@ module RestModule {
return await this.parseResponse(response) return await this.parseResponse(response)
} }
async patch({ path = "", queryString = "", headers = {}, json = {} }) {
this.headers = {
...this.config.defaultHeaders,
...headers,
}
const response = await fetch(this.config.url + path + queryString, {
method: "PATCH",
headers: this.headers,
body: JSON.stringify(json),
})
return await this.parseResponse(response)
}
async delete({ path = "", queryString = "", headers = {} }) { async delete({ path = "", queryString = "", headers = {} }) {
this.headers = { this.headers = {
...this.config.defaultHeaders, ...this.config.defaultHeaders,