I'm having issues figuring out how to use Foursquare API (search capability) within my Angular application.
My project structure looks like this
app
components
app.ts
search.ts
services
foursquare.ts
typings
boot.ts
index.html
foursquare.ts looks like this
import {Injectable, Inject} from 'angular2/core';
import {Http, Response, RequestOptions, Headers, Request, RequestMethod} from 'angular2/http';
import 'rxjs/add/operator/map';
const CLIENT_ID = 'My client id';
const SECRET = 'My secret';
const URL : string = 'https://api.foursquare.com/v2/venues/search?client_id='+CLIENT_ID+'&client_secret='+SECRET+'&v=20130815';
@Injectable()
export class FoursquareService {
constructor(public http:Http) {
this.http = http;
}
foursquareGet(data) {
return this.http.get(URL+data).map(res => res.json());
}
}
And I am trying to use it within search.ts in a following way
import {Component} from 'angular2/core';
import {FoursquareService} from '../../services/foursquare'
@Component({
templateUrl : 'app/components/new-listing/new-listing.html',
providers : [FoursquareService]
})
export class NewListingComponent {
constructor(service : FoursquareService) {
console.log(service.foursquareGet('&ll=40.7,-74&query=sushi'));
}
}
This returns an Observable inside console that I have no idea how to use, and would rather like it to return an array of JSON objects that meet the criteria. I'm trying to follow documentation on this, but have no idea what step to do next.