Angular 获取帮助

Angular 获取帮助,angular,angular-cli,Angular,Angular Cli,我正在尝试访问一个api。api文档给我的示例在我的bash shell(git bash)中工作,但是试图使用Angular构建应用程序,我无法让它工作 当我将给出的示例粘贴到git bash中时,效果很好: curl -v 'https://api.r8.beer/v1/api/graphql/' \ -H 'content-type: application/json' \ -H 'accept: application/json' \ -H 'x-api-key: <my-api-

我正在尝试访问一个api。api文档给我的示例在我的bash shell(git bash)中工作,但是试图使用Angular构建应用程序,我无法让它工作

当我将给出的示例粘贴到git bash中时,效果很好:

curl -v 'https://api.r8.beer/v1/api/graphql/' \
-H 'content-type: application/json' \
-H 'accept: application/json' \
-H 'x-api-key: <my-api-key>' \
--data-binary '{"query":"query {\n beer(id: 4934) {\n id\n name\n 
}\n}","variables":"{}","operationName":null}'

我离这里有多近???

如果您将数据传递给cUrl并指定一个内容类型,那么您正在执行POST请求

试试那样的

getBeer(){

    let data = {
        query:"{\n beer(id: 4934) {\n id\n name\n }\n}",
        variables:"{}",
        operationName:null
    };

    return this.http.post('https://api.r8.beer/v1/api/graphql/', data, {
    headers:{
       'x-api-key': '<my-api-key>'}
      });
 }
getBeer(){
让数据={
查询:“{\n beer(id:4934){\n id\n name\n}\n}”,
变量:“{}”,
操作名称:null
};
返回此.http.post('https://api.r8.beer/v1/api/graphql/",数据,{
标题:{
'x-api-key':''}
});
}
--data-binary '{"query":"query {\n beer(id: 4934) {\n id\n name\n 
}\n}","variables":"{}","operationName":null}'
getBeer(){

    let data = {
        query:"{\n beer(id: 4934) {\n id\n name\n }\n}",
        variables:"{}",
        operationName:null
    };

    return this.http.post('https://api.r8.beer/v1/api/graphql/', data, {
    headers:{
       'x-api-key': '<my-api-key>'}
      });
 }