Fixing REST PUT using POST as per #3227.
This commit is contained in:
parent
bbcee67e4c
commit
aebd39d874
|
@ -23,9 +23,6 @@ function formatResponse(resp) {
|
||||||
try {
|
try {
|
||||||
resp = JSON.parse(resp)
|
resp = JSON.parse(resp)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(
|
|
||||||
"Error parsing JSON response. Returning string in array instead."
|
|
||||||
)
|
|
||||||
resp = { response: resp }
|
resp = { response: resp }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,13 +142,11 @@ module RestModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseResponse(response: any) {
|
async parseResponse(response: any) {
|
||||||
switch (this.headers.Accept) {
|
const contentType = response.headers.get("content-type")
|
||||||
case "application/json":
|
if (contentType && contentType.indexOf("application/json") !== -1) {
|
||||||
return await response.json()
|
return await response.json()
|
||||||
case "text/html":
|
} else {
|
||||||
return await response.text()
|
return await response.text()
|
||||||
default:
|
|
||||||
return await response.json()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +189,7 @@ module RestModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(this.getUrl(path, queryString), {
|
const response = await fetch(this.getUrl(path, queryString), {
|
||||||
method: "POST",
|
method: "PUT",
|
||||||
headers: this.headers,
|
headers: this.headers,
|
||||||
body: JSON.stringify(json),
|
body: JSON.stringify(json),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue