solusi untuk masalah gagal fecth API

Access to fetch at 'https://api.edamam.com/search?q=chicken&app_id=767e79da&app_key=35710f044b03255ccb8be3a2bfbab321' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
avatar ishafiuddinismail

@ishafiuddinismail

1 Kontribusi 1 Poin


Jawaban

Masalah CORS ini, bisa jadi sengaja dari developer untuk memproteksi APInya

cek di dokumentasi edamam nya


Do you support direct requests from the browser (AJAX, JSONP, CORS)?


- For the Recipe Analysis API and Nutrition Data API the answer is no and we currently don't plan to. There are two reasons behind this:


First, to access one of these APIs the request needs to include valid credentials (for example app_id and app_key). This would make it very easy for somebody to steal them.

The second reason is, that direct access means direct charges from Edamam caused by the use of your site. Instead we expect that our customers develop server-side solutions that save the responses.

For the Diet Recommendations API and Recipe Search API we do support JSONP through the callback parameter. However, we are discouraging this, because of the same security issue.
avatar hilmanski

@hilmanski

2338 Kontribusi 1962 Poin


Login untuk gabung berdiskusi
premium logo tube

Hey, sedang ada diskon premium untuk akses semua kelas. Lihat di sini