{"id":23582667,"url":"https://github.com/anucha-tk/nextjs-pokedex","last_synced_at":"2025-11-02T19:30:23.367Z","repository":{"id":116852113,"uuid":"575460863","full_name":"anucha-tk/nextjs-pokedex","owner":"anucha-tk","description":"pokedex build with nextjs, tailwind and more...","archived":false,"fork":false,"pushed_at":"2024-01-05T02:38:29.000Z","size":1792,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-27T01:12:26.984Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anucha-tk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"theodorusclarence","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-12-07T15:06:13.000Z","updated_at":"2022-12-07T15:07:02.000Z","dependencies_parsed_at":"2024-01-05T03:48:41.476Z","dependency_job_id":null,"html_url":"https://github.com/anucha-tk/nextjs-pokedex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anucha-tk%2Fnextjs-pokedex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anucha-tk%2Fnextjs-pokedex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anucha-tk%2Fnextjs-pokedex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anucha-tk%2Fnextjs-pokedex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anucha-tk","download_url":"https://codeload.github.com/anucha-tk/nextjs-pokedex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239399807,"owners_count":19632022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-27T01:12:28.427Z","updated_at":"2025-11-02T19:30:23.303Z","avatar_url":"https://github.com/anucha-tk.png","language":"TypeScript","funding_links":["https://github.com/sponsors/theodorusclarence"],"categories":[],"sub_categories":[],"readme":"# PokeApi\n\nthis project is create from nextjs + tailwind css and PokeApi.co\n\n# Tech stack\n\n- Front end: [NextJS](https://nextjs.org/)\n- Css: [Tailwind css](https://tailwindcss.com/)\n- Api: [pokeapi](https://pokeapi.co/)\n- state management \u0026 api Cache: [Redux toolkit RTK](https://redux-toolkit.js.org/)\n\n# Table of contents\n\n- [PokeApi](#pokeapi)\n- [Tech stack](#tech-stack)\n- [Table of contents](#table-of-contents)\n- [Features and Tactical](#features-and-tactical)\n  - [Custom Redux toolkit RTK Query and Paginate](#custom-redux-toolkit-rtk-query-and-paginate)\n  - [LoadJSON file](#loadjson-file)\n- [Roadmap](#roadmap)\n\n# Features and Tactical\n\n## Custom Redux toolkit RTK Query and Paginate\n\n**Problem:** when we get [https://pokeapi.co/api/v2/pokemon/](https://pokeapi.co/api/v2/pokemon/) image by pokemon id not found,\n\n\u003cdetails\u003e\n\u003csummary\u003eResponse from Api\u003c/summary\u003e\n\n```json\n{\n  \"count\": 1154,\n  \"next\": \"https://pokeapi.co/api/v2/pokemon/?offset=5\u0026limit=5\",\n  \"previous\": null,\n  \"results\": [\n    {\n      \"name\": \"bulbasaur\",\n      \"url\": \"https://pokeapi.co/api/v2/pokemon/1/\"\n    },\n    {\n      \"name\": \"ivysaur\",\n      \"url\": \"https://pokeapi.co/api/v2/pokemon/2/\"\n    },\n    {\n      \"name\": \"venusaur\",\n      \"url\": \"https://pokeapi.co/api/v2/pokemon/3/\"\n    },\n    {\n      \"name\": \"charmander\",\n      \"url\": \"https://pokeapi.co/api/v2/pokemon/4/\"\n    },\n    {\n      \"name\": \"charmeleon\",\n      \"url\": \"https://pokeapi.co/api/v2/pokemon/5/\"\n    }\n  ]\n}\n```\n\n\u003c/details\u003e\n\n**solve:** we use queryFn() for multiple query on single RTK query\n\n\u003cdetails\u003e\n\u003csummary\u003eResponse api with queryFn()\u003c/summary\u003e\n\n```json\n{\n  data: [\n    {\n      abilities: {},\n      name: {},\n      species: {}\n      sprites: {}, // \u003c-- 👈 pokemon images there're here\n    },\n    {...},\n  ]\n}\n```\n\n\u003c/details\u003e\n\n\u003e `hint` ⚠️ queryFn return {data: ...} or {error: ...}\n\n```typescript\n// store/slices/pokemonSlice.ts\ngetPokemonNames: builder.query\u003cPokeNameApiResponse[], number\u003e({\n  async queryFn(_arg, _queryApi, _extraOptions, fetchWithBQ) {\n    const limit = 3;\n    const page = limit * _arg;\n    const fetchAllPokemons = await fetchWithBQ(\n      `/pokemon/?limit=3\u0026offset=${page}`\n    );\n    if (fetchAllPokemons.error)\n      return { error: fetchAllPokemons.error as FetchBaseQueryError };\n\n    const res = fetchAllPokemons.data as PokeApiResponse;\n    const pokemonNames = res.results.map((e) =\u003e e.name);\n\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    const pokemons: any = await Promise.all(\n      pokemonNames.map(async (e) =\u003e {\n        const res = await fetchWithBQ(`/pokemon/${e}`);\n        return res.data;\n      })\n    );\n    return pokemons\n      ? { data: pokemons as PokeNameApiResponse[] }\n      : { error: pokemons.error as FetchBaseQueryError };\n  },\n}),\n```\n\n### LoadJSON file\n\n```typescript\n// api/staticdata.ts\nimport { promises as fs } from 'fs';\nimport { NextApiRequest, NextApiResponse } from 'next';\nimport path from 'path';\n\nexport default async function handler(\n  _req: NextApiRequest,\n  res: NextApiResponse\n) {\n  //Find the absolute path of the json directory\n  const jsonDirectory = path.join(process.cwd(), 'data');\n  //Read the json data file data.json\n  const fileContents = await fs.readFile(jsonDirectory + '/en.json', 'utf8');\n  //Return the content of the data file in json format\n  res.status(200).json(fileContents);\n}\n```\n\n# Roadmap\n\n- [x] State management with Redux toolkit RTK\n- [x] Pagination\n- [x] Single pokemon character\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanucha-tk%2Fnextjs-pokedex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanucha-tk%2Fnextjs-pokedex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanucha-tk%2Fnextjs-pokedex/lists"}