Google places API

Google places API
0.0 0

#1

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?


#2

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


#3

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.


#4
"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


#5

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.


#6

Check your browser console, you get a CORS error. You can solve it by prepending your url with: https://cors-anywhere.herokuapp.com/:

var googleAPI = "https://cors-anywhere.herokuapp.com/https://maps.googleapis.com/...";

#7

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!


#8

So, did you try the browser console?


#9

This is what i got.
Object

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.


#10

So it works?


#11

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?


#12

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.


#13

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