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:
parent
b30a5a21d1
commit
7d95acb402
1 changed files with 10 additions and 26 deletions
|
@ -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",
|
||||
},
|
||||
}
|
||||
|
||||
fetch(apiUrl, options)
|
||||
.then(response => checkError(response, 1))
|
||||
.then(response => {
|
||||
if (response.status == 204) {
|
||||
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"
|
||||
)
|
||||
} else {
|
||||
setError(response.message || response.statusText)
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
setError(error)
|
||||
})
|
||||
},
|
||||
error => {}
|
||||
)
|
||||
},
|
||||
},
|
||||
name: "EHoldingsLocalTitlesFormConfirmDelete",
|
||||
|
|
Loading…
Reference in a new issue