Closed Aarbel closed 5 years ago
Hi @elbywan, thanks a lot for your work !
I face a weird error with Firefox (no errors happen in Chrome and Safari), which cause the browser to refresh. Do you know the origin of the problem ? Format of body ?
Thanks a lot for your help !
const addAuthTokenMiddleware = next => (url, opts) => next(url, { ...opts, headers: { ...opts.headers, Authorization: `Bearer ${getToken()}`, }, }); const defaultWretch = wretch() .url('/api') .options({ credentials: 'include' }) .middlewares([addAuthTokenMiddleware]); const response = defaultWretch .url(url) .post(body) .json() .catch(error => { console.error('Clovis ServerApiJSON post error :', { error: error, url: url, body: body, }); });
Ok i just solved the error after hours of research.
Firefox refreshes the page on default html <button> elements and consider them as "submit". That makes the wretch request fail.
<button>
Putting type="button" on the html element solved the problem.
Hi @elbywan, thanks a lot for your work !
I face a weird error with Firefox (no errors happen in Chrome and Safari), which cause the browser to refresh. Do you know the origin of the problem ? Format of body ?
Thanks a lot for your help !