Hi everyone!
I got a problem with the fourth part of the Ravenous project; i’ve finished it and it should work. However, when i clock on the let’s go button, i have this message:
Unhandled Rejection (TypeError): this.setState is not a function
with the following:
17 |
18 | searchYelp(term, location, sortBy) {
19 | Yelp.search(term, location, sortBy).then(businesses => {>
20 | this.setState({
21 | ^ businesses: businesses
22 | })
23 | });
So i think the problem comes from my this.setState object, but i don’t know to resolve this.
Hello, since it’s saying this.setState
isn’t a function and you pass searchYelp
to another component, then you need to double check how you’re binding this
to that function in your constructor. You’re missing something on that line.
1 Like
Also, you should be aware that the cors-anywhere.herokuapp.com
site that is used to get around issues with CORS when sending the Yelp API requests is currently down or extremely slow.
I’m only mentioning that because you have another issue in your Yelp.js
file that you’ll discover once you fix the first issue, but it will be difficult to troubleshoot if the site continues to act up.
Hint about that other issue in case you need it
json
is a function, not a property.
Everything’s fine now, i’ve added what was needed on the binding line (as followed: this.searchYelp = this.searchYelp.bind(this)
and also fixed the other issue on Yelp.js, turning json into a function (response.json()).
Thank you for your help!
2 Likes