1
0
Fork 0
mirror of synced 2024-07-02 13:01:09 +12:00

Fixing REST PUT using POST as per #3227.

This commit is contained in:
mike12345567 2021-11-03 13:12:20 +00:00
parent 7b73a8dbe7
commit f8b2429bd0
2 changed files with 6 additions and 11 deletions

View file

@ -23,9 +23,6 @@ function formatResponse(resp) {
try {
resp = JSON.parse(resp)
} catch (err) {
console.error(
"Error parsing JSON response. Returning string in array instead."
)
resp = { response: resp }
}
}

View file

@ -142,13 +142,11 @@ module RestModule {
}
async parseResponse(response: any) {
switch (this.headers.Accept) {
case "application/json":
return await response.json()
case "text/html":
return await response.text()
default:
return await response.json()
const contentType = response.headers.get("content-type")
if (contentType && contentType.indexOf("application/json") !== -1) {
return await response.json()
} else {
return await response.text()
}
}
@ -191,7 +189,7 @@ module RestModule {
}
const response = await fetch(this.getUrl(path, queryString), {
method: "POST",
method: "PUT",
headers: this.headers,
body: JSON.stringify(json),
})