Open eduherminio opened 2 years ago
Probably a bit late for OP, but I think the problem stems from your typing of options in transformOptions. The type should be AxiosRequestConfig
, not RequestInit
Rather than
transformOptions(options: RequestInit): Promise<RequestInit> {
It should be
transformOptions(options: AxiosRequestConfig): Promise<AxiosRequestConfig> {
Then, with the correct typing, there's no need to new up an object nor call append on it, it's as simple as
options.headers = {
...options.headers,
Authorization: `Bearer ${this.token}`,
};
return Promise.resolve(options);
After having a working app generated using
Fetch
template I've switched toAxios
one andAuthorization
header aren't longer sent in the server requests.This is the generated client code. In the debugger point
transformedOptions_.headers.get("Authorization")
still has the right headerTested with
NSwag.MsBuild 13.15.9
server side and bothAxios
^0.21.1
and^0.26.0
client side