Closed masterHAWK99 closed 1 year ago
Thanks! Let's instead add a new option
stringify
that defaults to JSON.stringify. That way no breaking change
What do you mean? Changing the replacer
parameter to stringify
?
I came up with something like this:
export function mande(
baseURL: string,
stringify: (data: any) => string = JSON.stringify,
passedInstanceOptions: OptionsRaw = {},
fetchPolyfill?: Window['fetch']
): MandeInstance {
No, let's keep the same arguments (non breaking) and add a new property to the options
Like that?
function _fetch(...) {
//...
if (method[0] === 'P' && data)
mergedOptions.body = passedInstanceOptions.stringify
? passedInstanceOptions.stringify(data)
: JSON.stringify(data)
}
export interface OptionsRaw<R extends ResponseAsTypes = ResponseAsTypes>
extends Omit<Options<R>, 'headers' | 'signal'> {
//...
stringify?: (data: any) => string
}
Yes
Thanks, I couldn't push so I merged locally
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
fix #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
Close #382