-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed as not planned
Description
It's useful to have urls for API endpoints stored as constants in an app, so that they can be reused safely. For example, I might use API.getSomeResource.url as the query property in an RTK Query endpoint, and also use API.getSomeResource.url as the url argument for mocking with, say, MirageJS, cy.intercept (in Cypress.io), or an other mocking framework.
Since the baseApi winds up being a catalog of all the endpoints used, it would be very helpful if it exposed information about those endpoints. There is indeed already baseApi.endpoints but it doesn't include this data.
Perhaps baseApi.endpoints could add the following fields: (excuse the imprecise type annotations)
type ExtendedEndpointLogic = EndpointLogic & {
query: typeof createApi.endpoints[].query
method: RESTMethod // "get", "post", etc.
// and perhaps even!
transformResponse: typeof createApi.endpoints[].transformResponse
}(Indeed, query would be a function)
geritol
Metadata
Metadata
Assignees
Labels
No labels