Ravenous project Part 4 (Error 403 (forbidden))

Hey everyone,

I come to you because I have an issue that I don’t really understand. I just finished the last part of the project ( I thought so at least :joy:) and everything render properly. But when I try to use the apply nothing change, so i check the console and i got two message that appeared :

  1. GET https://cors-anywhere.herokuapp.com/https://api.yelp.com/v3/businesses/search?term=sushi&location=toronto&sort_by=best_match 403 (Forbidden)

  2. VM807:1 Uncaught (in promise) SyntaxError: Unexpected token S in JSON at position 0

I don’t really understand this message so I would be really grateful if anyone could help me with our guide me to fix this bug.

Here is a part of the code from where the problem seem to come from :

const apiKey = '****'; // I have a key from Yelp 

const Yelp = {
    search(term, location, sortBy) {
        return fetch(
            {headers: {
                Authorization: `Bearer ${apiKey}`
            response => {
                return response.json()
            jsonResponse => {
                if(jsonResponse.businesses) {
                    return jsonResponse.businesses.map(business => ({
                            id : business.id,
                            imageSrc: business.imageSrc,
                            name: business.name,
                            address: business.address,
                            city: business.city,
                            state: business.state,
                            zipCode: business.zipCode,
                            category: business.category,
                            rating: business.rating,
                            reviewCount: business.reviewCount

export default Yelp;

Last think, I verified the code solution and it doesn’t look like i made any error … (as far as i know :sweat_smile:).

Thank in advance

Hello, I haven’t examined your code too deeply but based on the error message and what I know about recent changes to the CORS Anywhere solution recommended in the project instructions, there’s a good chance your code is fine.

Normally I wouldn’t try to refer you to another thread, but there’s a lot of valuable information here, including a couple workarounds. Check this out: CORS Anywhere Issue with Ravenous

One temporary workaround is visiting a page and clicking a button to give you proper responses. The other is to use an alternate service, which isn’t official so you can decide if you want to use it, though many have had success.

Thanks a lot for you answer! I’ll check the other post :pray: