-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
butter.page.retrieve and butter.page.list have incorrect return type #89
Comments
Hi @AlyonaSidarenka I'm sorry you're going through this! I'm tagging @courcelan from our team to help with this issue. |
Hi @AlyonaSidarenka, You are corrected that the response was updated when we switched to fetch; we no longer have Is your main concern here about the TS definition on the return type or that its no longer We are working on updating the definition files to reflect the changes as you described. Thanks! |
This updates the response structure to echo schema expected from TypeScript definitions and the same data schema/structure as return in buttercms-js version 1. The response no longer returns the `xsrfCookieName`, `xsrfHeaderName`, and `maxContentLength` in `response.config` as they are not in use by native fetch. Additionally, `response.config` returns only the fully formed `url` (`response.config.url`) rather than breaking it down in discrete parts. If needed, please use the native `URL` API in your code to get similar datapoints. This PR fixes the issues raised in #89. bump package version to 2.1.0
…and v1 This updates the response structure to echo schema expected from TypeScript definitions and the same data schema/structure as return in buttercms-js version 1. The response no longer returns the `xsrfCookieName`, `xsrfHeaderName`, and `maxContentLength` in `response.config` as they are not in use by native fetch. Additionally, `response.config` returns only the fully formed `url` (`response.config.url`) rather than breaking it down in discrete parts. If needed, please use the native `URL` API in your code to get similar datapoints. This PR fixes the issues raised in #89. bump package version to 2.1.0
@courcelan thanks, confirm that using v2.1.0 fixes the issue |
When making request for page:
const response = await butter.page.retrieve<ButterPageFieldstype, "page_type_value">( PAGE_TYPE, slug, params, );
ACTUAL result:
According to typescript files return type is:
Promise<Response<PageRetrieveResponse<PageModel, PageType, PageSlug>>>
following this, page should be available this way:
const page = response.data.data
;but in reality page is accessible like that:
const page = response.data
;EXPECTED type is
const response: Promise<PageRetrieveResponse<ButterPageFieldstype, "page_type_value">>
Note: same for
await butter.page.list
ACTUAL return type:
Promise<Response<PageListResponse<PageModel, PageType>>>;
;EXPECTED:
Promise<PageListResponse<PageModel, PageType>>;
;might be related to the fact that you guys switched from axios to fetch and axios wraps response with data object
The text was updated successfully, but these errors were encountered: