|
angular.module('starter.services', []) |
|
|
|
/** |
|
* A simple example service that returns some data. |
|
*/ |
|
.factory('Products', function($http) { |
|
return { |
|
get: function(productId) { |
|
var product = null; |
|
// example json returned |
|
// {"id":"cover-702e5d","title":"Round Cushion Cover with red flower"} |
|
// Simple index lookup |
|
$http({ |
|
url: "http://localhost:3000/api/merchants/products/"+ productId +".json", |
|
method: "GET", |
|
headers: { |
|
'Accept': 'application/vnd.foo.v1', |
|
'X-AUTHENTICATION-TOKEN': 'foobar' |
|
} |
|
}).success(function(data, status, headers, config){ |
|
console.log(status); |
|
}).then(function(response){ |
|
product = response.data; |
|
console.log(response.data); |
|
}) |
|
return product; |
|
} |
|
} |
|
}); |