Bug 32939: Use APIClient to replace some more fetch calls

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2023-02-21 12:50:02 +01:00 committed by Tomas Cohen Arazi
parent b30a5a21d1
commit 7d95acb402
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -32,7 +32,7 @@
<script>
import { APIClient } from "../../fetch/api-client.js"
import { setMessage, setError } from "../../messages"
import { setMessage } from "../../messages"
export default {
data() {
@ -59,32 +59,16 @@ export default {
},
onSubmit(e) {
e.preventDefault()
let apiUrl =
"/api/v1/erm/eholdings/local/titles/" + this.title.title_id
const options = {
method: "DELETE",
headers: {
"Content-Type": "application/json;charset=utf-8",
const client = APIClient.erm
client.localTitles.delete(this.title.title_id).then(
success => {
setMessage(this.$__("Title deleted"))
this.$router.push(
"/cgi-bin/koha/erm/eholdings/local/titles"
)
},
}
fetch(apiUrl, options)
.then(response => checkError(response, 1))
.then(response => {
if (response.status == 204) {
setMessage(this.$__("Title deleted"))
this.$router.push(
"/cgi-bin/koha/erm/eholdings/local/titles"
)
} else {
setError(response.message || response.statusText)
}
})
.catch(error => {
setError(error)
})
error => {}
)
},
},
name: "EHoldingsLocalTitlesFormConfirmDelete",