ofetch
ofetch copied to clipboard
Support usage of URLSearchParams as a value for query / params
Describe the feature
I naively used URLSearchParams in order to prepare the parameters I want to send along the request, however those are not read if I use an interceptor later on.
const $fetch = ofetch.create({
baseURL: this.baseUrl,
onRequest: ({ options }) => {
options.query ||= new URLSearchParams();
options.query.set('token', this.token);
}
});
const query = new URLSearchParams({
title,
});
$fetch(url, { query })
Is it something unwanted, or is a contribution welcome for this one ?
Additional information
- [X] Would you be willing to help implement this feature?
need add to end:
options.query = Object.fromEntries(options.query.entries())