I'm trying to use the Pinterest JavaScript SDK to get some pin data for a project. I have a method in a Pinterest service I created that gets called in my HomeController. I tried throwing the response inside of a promise so I could put it on my HomeController's $scope
and display it in my view. However, $scope.pins is undefined in my view. Why is it undefined
? Seems like the promise is working. Still learning promises.
Pinterest Service
function getBoardPins (id) {
return new Promise(function (resolve, reject) {
PDK.request('/v1/boards/' + id + '/pins/', 'GET', {fields: 'id,link,url,creator,board,created_at,note,color,counts,media,attribution,image,metadata'}, function (response) {
if (response) {
resolve(response);
}
reject();
});
});
}
Home Controller
Pinterest.getBoardPins('490329546869188172').then(function (response) {
$scope.pins = response.data;
});
View
<h1>Pinterest</h1>
<div ng-repeat="pin in pins">
<div>{{pin}}</div>
</div>