acacode / acacode/swagger-typescript-api

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

未關閉
#345 3 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
4.1k
分支
436
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。