Skip to content

Commit

Permalink
remove dependency on httpbin instead faking fetch in example
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus committed Aug 9, 2023
1 parent 07a20ae commit ed737b1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,18 @@ <h2 tabindex="-1" id="success2" class="success" hidden>Your submission was succe
let focusedInput
const nativeFetch = window.fetch
const fakeFetch = function (_, options) {
const path = `https://httpbin.org/status/${options.body.get('value') === '422' ? '422' : '200'}`
return nativeFetch(path, options)
if (options.body.get('value') === '422') {
return Promise.resolve(
new Response(JSON.stringify({message: '422'}), {
status: 422,
}),
)
}
return Promise.resolve(
new Response(JSON.stringify({message: 'success'}), {
status: 200,
}),
)
}
window.fetch = fakeFetch

Expand Down

0 comments on commit ed737b1

Please sign in to comment.