acacode / acacode/swagger-typescript-api

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

Đang mở
#345 3 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
4.1k
Fork
436
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.