Yelp / yelp-fusion

Yelp Fusion API
https://yelp.com/developers
MIT License
401 stars 394 forks source link

Fetch api request to yelp not responding #625

Closed dmakuto closed 9 months ago

dmakuto commented 3 years ago

Overview

)_

Description

(I get the error below at the browser's console )

Access to fetch at 'https://thingproxy.freeboard.io/fetch/https://api.yelp.com/v3/businesses/search?term=fish&location=phoenix&sort_by=best_match' from origin 'https://bitepoint.link' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.

More information

(Fill this section out if applicable (for things like bugs or questions))

Endpoint

(GET https://api.yelp.com/v3/businesses/search)

Parameters or Sample Request

'https://thingproxy.freeboard.io/fetch/https://api.yelp.com/v3/businesses/search?term=fish&location=phoenix&sort_by=best_match'

Response

(SAMPLE)

{
              id: business.id,
              imageSrc: business.image_url,
              name: business.name,
              address: business.location.address1,
              city: business.location.city,
              state: business.location.state,
              zipCode: business.location.zip_code,
              category: business.categories[0].title,
              rating: business.rating,
              reviewCount: business.review_count,
            };

Extra information

(Help me to use my https://bitepoint.link app for my portfolio at https://derickmakuto.tech)

LanoCodes commented 3 years ago

Hi, I am new to the whole commenting on issues/developing in general but I am getting the same issue as well when attempting to do the same!

dmakuto commented 3 years ago

Hi, I have no solution n still waiting for yelp support to respond. Kind regards, Derick Simiyu

Get Outlook for Androidhttps://aka.ms/ghei36


From: LanoCodes @.> Sent: Tuesday, April 27, 2021 9:48:59 PM To: Yelp/yelp-fusion @.> Cc: Derick Makuto Simiyu @.>; Author @.> Subject: Re: [Yelp/yelp-fusion] Fetch api request to yelp not responding (#625)

Hi, I am new to the whole commenting on issues/developing in general but I am getting the same issue as well when attempting to do the same!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Yelp/yelp-fusion/issues/625#issuecomment-827836289, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKDFQ6MKNJDJUY2KPTI4BQLTK4BJXANCNFSM43CC5ASQ.

bizmate commented 3 years ago

@dmakuto I am not sure why you expect for Yelp to troubleshoot this problem. I will give you a suggestion point you at why you might not get an answer. In your code you are using a proxy and there is an obvious and clear output of what is failing. 1 - do not use a proxy 2 - investigate https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors so you understand why the error is displayed

Notice this is not Stackoverflow and issues opened here are for bugs that are clearly related to Yelp Fusion and not due to external factors.

dmakuto commented 3 years ago

Thank you.

Get Outlook for Androidhttps://aka.ms/ghei36


From: Diego Gullo @.> Sent: Saturday, May 1, 2021 2:12:56 PM To: Yelp/yelp-fusion @.> Cc: Derick Makuto Simiyu @.>; Mention @.> Subject: Re: [Yelp/yelp-fusion] Fetch api request to yelp not responding (#625)

@dmakutohttps://github.com/dmakuto I am not sure why you expect for Yelp to troubleshoot this problem. I will give you a suggestion point you at why you might not get an answer. In your code you are using a proxy and there is an obvious and clear output of what is failing. 1 - do not use a proxy 2 - investigate https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors so you understand why the error is displayed

Notice this is not Stackoverflow and issues opened here are for bugs that are clearly related to Yelp Fusion and not due to external factors.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Yelp/yelp-fusion/issues/625#issuecomment-830614894, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKDFQ6L5KOICQQ65OY3TSYDTLPO3RANCNFSM43CC5ASQ.

dmakuto commented 3 years ago

Hallo Diego,

I have tried to hit the yelp end point without the proxy but I'm not successful. Below is my fetch request code:

const Yelp = { search(term, location, sortBy) { // return fetch(https://cors-anywhere.herokuapp.com/https://api.yelp.com/v3/businesses/search?term=${term}&location=${location}&sort_by=${sortBy}, return fetch( // https://thingproxy.freeboard.io/fetch/https://api.yelp.com/v3/businesses/search?term=${term}&location=${location}&sort_by=${sortBy}, https://api.yelp.com/v3/businesses/search?term=${term}&location=${location}&sort_by=${sortBy}, { mode: "no-cors" },

  {
    headers: {
      Authorization: `Bearer ${apiKey}`,
    },
  }
)
  .then((response) => {
    return response.json();
  })
  .then((jsonResponse) => {
    if (jsonResponse.businesses) {
      return jsonResponse.businesses.map((business) => {
        console.log(business);
        return {
          id: business.id,
          imageSrc: business.image_url,
          name: business.name,
          address: business.location.address1,
          city: business.location.city,
          state: business.location.state,
          zipCode: business.location.zip_code,
          category: business.categories[0].title,
          rating: business.rating,
          reviewCount: business.review_count,
        };
      });
    }
  });

}, };

Results on the browser: Unhandled Rejection (SyntaxError): Unexpected end of input (anonymous function) C:/innerLoop/my-projects/5. Git-Repos/test/bitepoints raw/src/util/Yelp.js:22 This screen is visible only in development. It will not appear if the app crashes in production. Open your browser’s developer console to further inspect this error. Click the 'X' or hit ESC to dismiss this message.

Dev tools console Output: Yelp.js:10 GET https://api.yelp.com/v3/businesses/search?term=fish&location=phoenix&sort_by=best_match net::ERR_ABORTED 400 search @ Yelp.js:10 searchYelp @ App.js:20 handleSearch @ SearchBar.js:50 callCallback @ react-dom.development.js:188 invokeGuardedCallbackDev @ react-dom.development.js:237 invokeGuardedCallback @ react-dom.development.js:292 invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:306 executeDispatch @ react-dom.development.js:389 executeDispatchesInOrder @ react-dom.development.js:414 executeDispatchesAndRelease @ react-dom.development.js:3278 executeDispatchesAndReleaseTopLevel @ react-dom.development.js:3287 forEachAccumulated @ react-dom.development.js:3259 runEventsInBatch @ react-dom.development.js:3304 runExtractedPluginEventsInBatch @ react-dom.development.js:3514 handleTopLevel @ react-dom.development.js:3558 batchedEventUpdates$1 @ react-dom.development.js:21871 batchedEventUpdates @ react-dom.development.js:795 dispatchEventForLegacyPluginEventSystem @ react-dom.development.js:3568 attemptToDispatchEvent @ react-dom.development.js:4267 dispatchEvent @ react-dom.development.js:4189 unstable_runWithPriority @ scheduler.development.js:653 runWithPriority$1 @ react-dom.development.js:11039 discreteUpdates$1 @ react-dom.development.js:21887 discreteUpdates @ react-dom.development.js:806 dispatchDiscreteEvent @ react-dom.development.js:4168 Yelp.js:22 Uncaught (in promise) SyntaxError: Unexpected end of input at Yelp.js:22

Help!


From: Diego Gullo @.> Sent: Saturday, May 1, 2021 11:12 AM To: Yelp/yelp-fusion @.> Cc: Derick Makuto Simiyu @.>; Mention @.> Subject: Re: [Yelp/yelp-fusion] Fetch api request to yelp not responding (#625)

@dmakutohttps://github.com/dmakuto I am not sure why you expect for Yelp to troubleshoot this problem. I will give you a suggestion point you at why you might not get an answer. In your code you are using a proxy and there is an obvious and clear output of what is failing. 1 - do not use a proxy 2 - investigate https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors so you understand why the error is displayed

Notice this is not Stackoverflow and issues opened here are for bugs that are clearly related to Yelp Fusion and not due to external factors.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Yelp/yelp-fusion/issues/625#issuecomment-830614894, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKDFQ6L5KOICQQ65OY3TSYDTLPO3RANCNFSM43CC5ASQ.