Angularjs + restangular, search albums & artists on spotify

I use restangular module to make connections to the spotify API and get search results of Albums and artists.

When i fetch an album or an artist , it is ok. The problem is when i pass params to restangular in order to search for results. restangular converts the symols & and = to special characters , and that makes the URL not working

For example i have the below snippet to search for albums/artists:

//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);
    });

But i get this FALSE URL: 在这里输入图像描述

Can somebody tell me how these symbols remain the same & and = ?


So there are two things wrong here.

  • URL search : you have two queries shown as one. ("q" and "type")
  • Result type : You said getList, the search API doesn't return an Array, it returns an object.

    Restangular.one('search') .get({ q: params, type: 'album,artist' }) .then(function (res) { console.log(res); });

  • 链接地址: http://www.djcxy.com/p/55654.html

    上一篇: Spotify Artist顶部曲目API返回参数“预览”

    下一篇: Angularjs + restangular,spotify搜索专辑和艺术家