我试图从API获取一些信息,但是我运行此代码后,我什么都没得到。 在firefox控制台上:
app.controller('Test', function($scope, $http) {
$http.post("http://api.olhovivo.sptrans.com.br/v0/Login/Autenticar?token=fde20482b4aecc6334096c63a39d714a0ca379dd7ab599c4312c93161ce17781").success(function(data) {
$scope.token = "Oi";
});
$http.get("http://api.olhovivo.sptrans.com.br/v0/Linha/Buscar?termosBusca=9").then(function(response) {
$scope.token = response;
});
// http://api.olhovivo.sptrans.com.br/v0/Login/Autenticar?token=fde20482b4aecc6334096c63a39d714a0ca379dd7ab599c4312c93161ce17781
}).config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.useXDomain = true;
$httpProvider.defaults.withCredentials = true;
delete $httpProvider.defaults.headers.common["X-Requested-With"];
$httpProvider.defaults.headers.common["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
$httpProvider.defaults.headers.common["Content-Type"] = "application/x-www-form-urlencoded";
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
$httpProvider.defaults.headers.post['Content-Length']= "0";
}]);
如果我在运行该代码后只在我的浏览器上粘贴并运行相同的URL(http://api.olhovivo.sptrans.com.br/v0/Linha/Buscar?termosBusca=9),它会返回我需要的所有json数据
由于