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