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

Diperbarui 2 tahun yang lalu

1 Jawaban:

<div>Masalah CORS ini, bisa jadi sengaja dari developer untuk memproteksi APInya<br><br>cek di <a href="https://developer.edamam.com/faq">dokumentasi edamam</a> nya<br><br><strong><br>Do you support direct requests from the browser (AJAX, JSONP, CORS)?<br></strong><br></div><div><br>- 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:<br><br></div><div><br>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.<br><br></div><div>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.<br><br></div><div>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.</div>

avatar hilmanski
@hilmanski

2670 Kontribusi 2132 Poin

Dipost 2 tahun yang lalu

Login untuk ikut Jawaban