如何在angularjs中使用POST

如何在angularjs中使用POST,angularjs,postman,Angularjs,Postman,我正在谷歌浏览器中使用Postman扩展来获取JSON数据。当我传入url并使用POST并提供api密钥的密钥授权和值时,我得到的是JSON数据。我想通过angular做同样的事情,这样我就可以使用JSON数据并将其显示在我的视图中 我在角度方面是新手,不知道如何使用POST方法 您可以这样做: $http.post(url, postData, { withCredentials: true, headers:{ 'Authorization': 'Basic' + token

我正在谷歌浏览器中使用Postman扩展来获取JSON数据。当我传入url并使用POST并提供api密钥的密钥授权和值时,我得到的是JSON数据。我想通过angular做同样的事情,这样我就可以使用JSON数据并将其显示在我的视图中


我在角度方面是新手,不知道如何使用POST方法

您可以这样做:

$http.post(url, postData,
{
    withCredentials: true,
    headers:{ 'Authorization': 'Basic' + token} //you add all your headers
}
).then(function(response){ 
   // here you treat your response
  }, function(error){ 
   // here you treat your error 
  }
);
$http.postrl,数据