Google places API

Hello everyone, I have done many of the projects on free code camp and the only one I really had problems with is the wiki because it was hard to get the api to work. Im now trying to do my own project that will pick a random food place to eat just by clicking a button, but I cant seem to get the googles places api to work. i can pull up the Json in the browser but when I try to put it in my project and try to console.log to see if in getting anything it does not work. has anyone had this problem and can help?

If you post your code(pen), there might be someone who can help you with it.

here is my pen, there is not much there since I just started. also I took out my api key… so whoever can help will have to have there own.

"error_message": "The provided API key is invalid.",
"html_attributions": [],
"results": [],
"status": "REQUEST_DENIED"

I get this problem.
You probably need to change this: key=key

I just put the key in there, I took it out because I don’t have any restrictions on it and Ive aways seen people be very careful about sharing them.

Check your browser console, you get a CORS error. You can solve it by prepending your url with:

var googleAPI = "";

I tried it and i got this.
“Log Skipped: Sorry, this log was too large for our console. You might need to use the browser console instead.”

I have a Mac and i have been using safari and when I put the api into the browser I get the json data it just doesn’t show up when I try to access it. im not sure what to do now since the CORS didn’t work. :frowning:
thank you so much for helping!

So, did you try the browser console?

1 Like

This is what i got.

html_attributions: [] (0)

results: [Object, Object, Object, Object, Object, Object, Object, Object, Object, Object] (10)

status: “OK”

I did this in both Crome and Safari and got the same thing. I also tried to do it without CORS and it said that I needed it in order to access the data.

So it works?

thats what I get in the browser console so that works, it just won’t pull up in the code pin console… is it possible there is a problem with code pen?

It is just too large, so you have to use the browser console to see it, but you can still do anything you want with the data.

thank you so much!!! it was that it was just to big, when i try to pull out specific data it comes out.