acacode / acacode/swagger-typescript-api

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

Aberta
#345 3 comentários 1 reação 0 responsáveis Ver no GitHub
Linguagem predominante
TypeScript
Estrelas
4.1k
Forks
436
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.