Skip to content

Commit ed737b1

Browse files
committed
remove dependency on httpbin instead faking fetch in example
1 parent 07a20ae commit ed737b1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

examples/index.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,18 @@ <h2 tabindex="-1" id="success2" class="success" hidden>Your submission was succe
4949
let focusedInput
5050
const nativeFetch = window.fetch
5151
const fakeFetch = function (_, options) {
52-
const path = `https://httpbin.org/status/${options.body.get('value') === '422' ? '422' : '200'}`
53-
return nativeFetch(path, options)
52+
if (options.body.get('value') === '422') {
53+
return Promise.resolve(
54+
new Response(JSON.stringify({message: '422'}), {
55+
status: 422,
56+
}),
57+
)
58+
}
59+
return Promise.resolve(
60+
new Response(JSON.stringify({message: 'success'}), {
61+
status: 200,
62+
}),
63+
)
5464
}
5565
window.fetch = fakeFetch
5666

0 commit comments

Comments
 (0)