Skip to content

Commit

Permalink
Allow $ajax to recover from aborted requests (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
imacrayon authored Oct 2, 2024
1 parent 06419b3 commit d7bf8dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@imacrayon/alpine-ajax",
"description": "An Alpine.js plugin for building server-powered frontends.",
"version": "0.9.0",
"version": "0.9.1",
"license": "MIT",
"author": "Christian Taylor",
"homepage": "https://alpine-ajax.js.org",
Expand Down
16 changes: 12 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,20 @@ function Ajax(Alpine) {
let method = options.method ? options.method.toUpperCase() : 'GET'
let body = options.body

let response = await request(el, targets, action, referrer, headers, method, body)
try {
let response = await request(el, targets, action, referrer, headers, method, body)

let history = ('history' in options) ? options.history : false
let focus = ('focus' in options) ? options.focus : true
let history = ('history' in options) ? options.history : false
let focus = ('focus' in options) ? options.focus : true

return render(response, el, targets, history, focus)
return render(response, el, targets, history, focus)
} catch (error) {
if (error.name === 'AbortError') {
return
}

throw error
}
}
})

Expand Down

0 comments on commit d7bf8dd

Please sign in to comment.