【发布时间】:2016-04-11 02:43:49
【问题描述】:
这似乎是一个简单的问题,我一定忽略了一些小问题。
我有一个访问 Spotify API 并搜索艺术家的函数。我知道通过普通 URL 访问此路由会返回结果。 (例如http://localhost:3001/search?artist=%27Linkin%20Park%27)执行此操作的代码如下:
router.get('/search', function(req, res, next)
{
var artist = req.param('artist');
console.log("Artist: " + artist);
smartSpot.getArtistID(artist, function(data)
{
console.log("Data: " + data);
res.json(data.id);
});
});
然后,前端有搜索艺术家的代码。这都是通过 Angular 完成的。
angular.module('smart-spot', [])
.controller('MainCtrl', [
'$scope', '$http',
function($scope, $http)
{
$scope.createPlaylist = function()
{
var artist = $scope.artist;
console.log(artist);
window.open("/login", "Playlist Creation", 'WIDTH=400, HEIGHT=500');
return $http.get('/search?=' + $scope.artist) //this doesn't pass in the artist
.success(function(data)
{
console.log(data);
});
}
}
]);
$http.get() 未正确传递 $scope.artist` 值。
【问题讨论】:
标签: javascript angularjs node.js express spotify