Because your code expects an array but the response is an object with the array nested inside. Log the full response, find the array in the correct field, and update your parsing to extract it before calling map.
Common Swiggy API Errors in React Projects and How to Resolve Them
Why do I get 'map is not a function' with the Swiggy API?
The answer
More FAQs in Common Swiggy API Errors in React Projects and How to Resolve Them
Use a development proxy in your bundler config or a small backend proxy. The proxy forwards the request server-side, bypassing the browser's CORS restrictions for local development.
It means you are calling the API too often and are being rate-limited. Cache responses so you do not re-request the same data, and reduce the frequency of your calls.
Because the fetch is using a cached response or not refetching on route change. Include the route parameter in the useEffect dependency array so the fetch re-runs when the route changes.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.