2017-03-10 90 views
0

我使用restangular模塊連接到spotify API並獲取專輯和藝術家的搜索結果。Angularjs + restangular,spotify上的搜索專輯和藝術家

當我獲取專輯或藝術家時,它是可以的。問題是當我通過params重新尋找結果。 restangular轉換symols &=特殊字符,這使得沒有工作

,比如我有下面的代碼片段搜索專輯/藝術家的網址:

//I pass : https://api.spotify.com/v1/search?q=album:lo%20artist:lo&type=album,artist 

const params = "album:lo+artist:lo&type=album,artist"; 
Restangular.all(SEARCH_END_POINT).getList({q: params}).then(function(data){ 
     console.log("All ok"); 
     console.log(data[0].name); 
    }, function(response) { 
     console.log("Error with status code", response.status); 
    }); 

,但我得到這個FALSE網址: enter image description here

有人可以告訴我這些符號是如何保持不變&=

回答

0

所以這裏有兩個錯誤。

  1. URL搜索:你有兩個查詢顯示爲一個。 (「q」和「type」)
  2. 結果類型:您說getList,搜索API不返回數組,它返回一個對象。

    Restangular.one( '搜索') 獲得({Q:PARAMS,類型: '專輯,藝術家'}) 。然後(函數(RES){ 的console.log(RES); }) ;

相關問題