angular.module('myapp', ['ngAnimate', 'ngTouch', 'restangular', 'ngRoute', 'ui.bootstrap'])
.config(function ($routeProvider, RestangularProvider) {
RestangularProvider.setBaseUrl('https://www.googleapis.com/calendar/v3/calendars/[email protected]/events?key=API KEY');
$routeProvider
.when('/', {
templateUrl: 'app/main/main.html',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/'
});
})
;
Trying to use the baseurl and then call it in the controller but unable to gain access to the JSON data when called in this way
angular.module('myapp')
.controller('MainCtrl', function (Restangular) {
Restangular.all("items").getList();
};
});
Any help on getting the request to not return on error would be greatly appreciated
Thanks
According to the docs, it looks as if the base URL for the Google Calender API is https://www.googleapis.com/calendar/v3
.
So after updating your Restangular reference to the baseUrl, your calls would look something more like this.
Restangular.one('/users/me/calendarList').getList().then(function(calendarList) {
//Do something with calendarList
});
Or something similar. You would need to reference the docs for other valid endpoints.
If you need to send a query param with every request then you can use setDefaultRequestParams for that purpose.