I'm using yeoman angular-fullstack to generate my project. So the client is angularJs (typeScript) and the backend is nodeJs. The problem is I got a variable and when I print it to the console, I get a very long string, (if u need to know its a photo_reference from googleplacesapi). And when I pass it to the with a http.get to the nodeJS api, and print it to the log I get the response Object object.
MainController
for (var photo of response.data.result.photos) {
this.getImages(photo);
console.log(photo.photo_reference);
}
getImages(photo_reference: string): void{
this.$http.get('/api/image/' + photo_reference).then((response) => {
});
}
NodeJs
export function show(req, res) {
console.log("photoreference:" + req.params.photoreference);
js – Passing Objects As Parameters. Due to the fact that you cannot access objects declared inside another function, you may need to grant other functions access to it. One way to do this in Node. js is by passing the object as a parameter to the function you'd like to use it in.
It is possible to access JS variable in . ejs file. You just need to pass the JS object as second parameter of res. render() method.
console. dir with the depth argument set will do the trick. This will print JSON objects to any arbitrary depth. Depth:null means print every level.
You are passing the wrong value to the getImages
function.
since the argument passed to getImages
has a photo_reference property it is an object so the logging is correct
pass the photo.photo_reference
to the function
for (var photo of response.data.result.photos) {
this.getImages(photo.photo_reference);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With