Restler with Cucumber

31 views Asked by At

I am totally new with protractor/cucumber and restler. I am using Typescript. Below is the code that I am using to hit the endpoint url and to get the response

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);
});

This prints the below:

In method:endpoint URL

undefined

I want the response and the responsecode to be printed.

1

There are 1 answers

0
keerthi On

Thanks for the response. Below code worked

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