-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathetsy_api.js
43 lines (37 loc) · 1.25 KB
/
etsy_api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// wrap the whole thing in an empty function
(function() {
// var app = angular.module('application name', [dependencies]);
// var app = angular.module('etsy-api', []);
// Example request for index page
angular.module('etsy', [])
.controller('FetchController', ['$scope', '$http',
function($scope, $http) {
shop_id = 'fiddlefishstore'
api_key = '&api_key=3ugcu6nyygcbysomqa2ed2ja';
fields = '&fields=title,url,price,quantity,description';
limit = '&limit=100';
includes = '&includes=MainImage';
callback = '&callback=JSON_CALLBACK';
etsyURL = 'https://openapi.etsy.com/v2/shops/'
+shop_id
+'/listings/active.js?method=GET'
+api_key
+fields
+limit
+includes
+callback
$http.jsonp(etsyURL).
success(function(data, status) {
$scope.status = status;
$scope.data = data;
console.log('status:');
console.log(status);
console.log('data response:');
console.log(data);
}).
error(function(data, status) {
$scope.data = data || "Request failed";
$scope.status = status;
});
}]);
})();