acacode / acacode/swagger-typescript-api

TypeError: Cannot read properties of undefined (reading 'mergeRequestParams')

Aperta
#345 3 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
4.1k
Fork
436
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

this may be an issue with next.js is anyone has set something like this up for it

I am recieving the error TypeError: Cannot read properties of undefined (reading 'mergeRequestParams')

On initial generation with the --axios flag though I get the same error without it
Am I missing something in the setup.

When I console.log this in the method it is undefined but the api instance is defined and being used
```ts
public request = async ({
secure,
path,
type,
query,
format,
body,
...params
}: FullRequestParams): Promise> => {
const secureParams =
((typeof secure === "boolean" ? secure : this.secure) &&
this.securityWorker &&
(await this.securityWorker(this.securityData))) ||
{};
console.log(this) // undefined
const requestParams = this.mergeRequestParams(params, secureParams);
const responseFormat = (format && this.format) || void 0;

if (type === ContentType.FormData && body && body !== null && typeof body === "object") {
requestParams.headers.common = { Accept: "*/*" };
requestParams.headers.post = {};
requestParams.headers.put = {};

body = this.createFormData(body as Record);
}

return this.instance.request({
...requestParams,
headers: {
...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}),
...(requestParams.headers || {}),
},
params: query,
responseType: responseFormat,
data: body,
url: path,
});
};
}
```

```ts
const cool = async () => {
const api2 = await new Api()
console.log('req', api2.request)
const res = await api2.api.tokensCreate({ email: 'someemail', password: 'pass' }, { secure: false })
console.log(api)
console.log(res)
}
useEffect(() => cool(), [])
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.