Catches an AbortError and performs a callback.
// 1 second timeout
wretch("...").addon(AbortAddon()).get().setTimeout(1000).json(_ =>
// will not be called if the request timeouts
)
-Optional
controller: Optional
contentType: Optional
url: stringOptional
body: Returns Resolver extends undefined ? Chain & WretchResponseChain<Self, Chain, Resolver> : ResolverOptional
url: stringOptional
url: stringOptional
url: stringOptional
body: Optional url: stringOptional
body: Optional url: stringOptional
body: Optional url: stringOptional
clear: Returns Wretch<Self, Chain, Resolver>// By default options are mixed in :
let w = wretch()
.options({ headers: { "Accept": "application/json" } })
.options({ encoding: "same-origin", headers: { "X-Custom": "Header" } });
console.log(JSON.stringify(w._options))
// => {"encoding":"same-origin", "headers":{"Accept":"application/json","X-Custom":"Header"}}
// With the flag, options are overridden :
w = wretch()
.options({ headers: { "Accept": "application/json" } })
.options(
{ encoding: "same-origin", headers: { "X-Custom": "Header" } },
true,
);
console.log(JSON.stringify(w._options))
// => {"encoding":"same-origin","headers":{"X-Custom":"Header"}}
Optional
replace: Returns Wretch<Self, Chain, Resolver>Optional
replace: Returns Wretch<Self, Chain, Resolver>Optional
clear: ClearOptional
replace: Returns Wretch<Self, Chain, Resolver>wretch("...").get().arrayBuffer(arrayBuffer => …)
-wretch("...").get().blob(blob => …)
-wretch("...").get().formData(formData => …)
-Read the payload and deserialize it as JSON.
-wretch("...").get().json((json) => console.log(Object.keys(json)));
+wretch("...").get().json((json) => console.log(Object.keys(json)));
wretch("...").get().res((response) => console.log(response.url));
-wretch("...").get().text((txt) => console.log(txt));
-Configuration object.
Optional
instance: Rest
...args: any[]
Parameters
Optional
options: ThrottlingCacheOptions