How to inject cookies in NightwatchJS?

How to inject cookies in NightwatchJS?

Hello Dipen,

Below is the code snippet to inject cookies in NightwatchJS:

var args = {

            data: {
                    email: "xxxx",
                    password: "xxxx"
                },
                headers: {
                    "Content-Type": "application/json"
                }
            };
            service.post("localhost", args, function(data, response) {
                global.Cookies = response.headers['set-cookie'].pop().split(';')[0]
                this.meServiceUrl = superTest.agent("localhost/users").get('');
                // Set cookie to get saved user session
                this.meServiceUrl.cookies = Cookies;
                this.meServiceUrl.set('Accept', 'application/json')
                    .expect('Content-Type', /json/)
                    .expect(200)
                    .end(function(err, res) {
                        usersApiResponse = res.body
                        usersServiceResponse.push(usersApiResponse)
                    console.log(usersServiceResponse)
                        console.log(usersApiResponse.result.length)
                    });
            });