-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Limit & offset not working on ListPokemon API using React Native #839
Comments
Seems like there's a problem in my react native client |
I tried create a vanilla Node.js project and used it and the dependency worked perfectly. |
The problem might be
On the browser, const cacheOptions = {
generateKey: buildKeyGenerator((request) => {
if (request.params) {
return {
method: request.method,
url: request.url,
params: request.params.toString(),
};
}
return defaultKeyGenerator(request);
}),
}; |
@nartc |
I reverted the usage of URLSearchParams and created a fn that builds the list url with the request params: /**
* List Pokemons
* @param offset The first item that you will get
* @param limit How many Pokemons Stats per page
* @returns A list of Pokemons
*/
public async listPokemons(offset?: number, limit?: number): Promise<NamedAPIResourceList> {
return new Promise<NamedAPIResourceList>((resolve, reject) => {
const url = getListURL(Endpoints.POKEMON, offset, limit);
this.api
.get<NamedAPIResourceList>(url)
.then((response: AxiosResponse<NamedAPIResourceList>) => resolve(response.data))
.catch((error: AxiosError<string>) => reject(error));
});
} export const getListURL = (endpoint: Endpoints, offset?: number, limit?: number): string => {
return `${endpoint}?offset=${offset ?? 0}&limit=${limit ?? 20}`;
}; |
I'll give this a try asap. Thanks Gabriel |
## [1.19.1](v1.19.0...v1.19.1) (2023-06-12) ### Bug Fixes * **clients:** revert usage of URLSearchParams [#839](#839) ([c92e365](c92e365))
@Gabb-c I put it to a test and it worked as I expected. Thank you 🙇🙇 |
What version of pokenode-ts are you using?
1.19.0
What version of Node.js are you using?
18.15.0
What operating system are you using?
macOS 13.3.1
Describe the Bug
I used
ListPokemon()
API using PokemonClient and it worked well without parameters. But when I passed in 2 params which arelimit
andoffset
, the result was exactly the same. And I found out that the problem only occurs when I use with React Native. It sent out a request looks like this:Here is the cURL that is created from the captured request:
Expected Behavior
It should return a new list of pokemon with new offset and new limit
To Reproduce
README.md
The text was updated successfully, but these errors were encountered: