Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 黄瓜炖菜_Typescript_Protractor_Cucumber_Restler - Fatal编程技术网

Typescript 黄瓜炖菜

Typescript 黄瓜炖菜,typescript,protractor,cucumber,restler,Typescript,Protractor,Cucumber,Restler,我对量角器/黄瓜和restler完全陌生。我正在使用打字脚本。下面是我用来点击端点url并获取响应的代码 Given('Hit the {string}', async (string) => { browser.quit() var data: any = get(string.replace(/\s+/g, '')); console.log("In method:" + string.replace(/\s+/g, '')); console.log(data.res

我对量角器/黄瓜和restler完全陌生。我正在使用打字脚本。下面是我用来点击端点url并获取响应的代码

Given('Hit the {string}', async (string) => {
  browser.quit()
  var data: any = get(string.replace(/\s+/g, ''));
  console.log("In method:" + string.replace(/\s+/g, ''));
  console.log(data.response);
});

这将打印以下内容: 在方法中:端点URL

未定义
我想要打印响应和响应代码

谢谢您的回复。下面的代码有效

Given('Hit the {string}', async (endpointUrl) => {
    await get(endpointUrl).on('complete', async (result, response) => {
        console.log(response.statusCode);
    });
});

我不熟悉restler包,但它可能是一个异步问题。试试这个
console.log(等待数据.response)