acacode / acacode/swagger-typescript-api

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

Abierto
#345 3 comentarios 1 reacción 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
4.1k
Forks
436
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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(), [])
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.