How do I fix a CORS error with the Swiggy API?
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.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Common Swiggy API Errors in React Projects and How to Resolve Them
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.
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
