如何将此API请求转换为Angular语法?

时间:2015-11-17 21:53:08

标签: angularjs api

这是来自Pushbot的示例API请求

  

curl -X POST \
  -H" x-pushbots-appid:appId" \
  -H" x-pushbots-secret:secret" \
  -H" Content-Type:application / json" \
  -d' {" platform" :数组,"标签" :数组,"声音" :字符串,"徽章" :String," schedule" :String," except_tags" :数组,"别名" :String," except_alias" :String," payload" :JSON,}' \   https://api.pushbots.com/push/all

我对RESTful API结构并不是很好,但据我所知-H表示此信息应位于http请求的标头中,而api的端点是提供的URL。现在-d代表什么?它是如何适应的?

我会像Angular JS一样开始:



$http.get('https://api.pushbots.com/push/all', {
    headers: {"x-pushbots-appid":"appID",
              "x-pushbots-secret":"secret",
              "Content-Type":"application/json"},
  
    data: '{ "platform" : Array ,  "tags" : Array ,  "sound" : String ,    "badge" : String ,  "schedule" : String ,  "except_tags" : Array ,  "alias" : String ,  "except_alias" : String ,  "payload" : JSON , }'
  
  .success(function(res){
    //handle response
    })
  
  .error(function(err,status){
    //handle error
    })




这是实现该示例的方法吗?

提前致谢!

0 个答案:

没有答案