javascript - Using a authentication login a parameter in request header in frisby -


i'm trying test requires authentication token login using frisby, the problem is: response of request string , not json , still havent figured out how working.

i've read few examples found googling havent been helpful far.

here's code:

var frisby= require('frisby');  frisby.create('login')     .post('http://mid.dev.psafe.com/my.api/security/authentication.svc/login',         {"user":"115303640577606155760"},         {json:true},         { headers: { 'content-type': 'application/json' }})     .expectstatus(200)     .afterjson(function (token) {         frisby.globalsetup({             request: {                 headers: { 'user-token': token }             }         });          frisby.create('list associated devices')             .post('http://mid.dev.psafe.com/my.api/apiadmin.svc/getdevices',                 {json:true})             .expectstatus(200)         .toss();     })  .toss(); 

here's got when ran test:

1) frisby test: login      [ post http://mid.dev.psafe.com/my.api/security/authentication.svc/login ]    message:      error: error parsing json string: unexpected token q     given: qo1dknvklcaomnxsrmvggfiqecqeztkjhnizitwyfkaxd9h1bwm1etigiincw5dz0    stacktrace:      error: error parsing json string: unexpected token q     given: qo1dknvklcaomnxsrmvggfiqecqeztkjhnizitwyfkaxd9h1bwm1etigiincw5dz0     @ _jsonparse (/usr/lib/node_modules/frisby/lib/frisby.js:1219:11)     @ frisby.<anonymous>     (/usr/lib/node_modules/frisby/lib/frisby.js:950:20)     @ null.<anonymous> (/usr/lib/node_modules/frisby/lib/frisby.js:1112:18)     @ timer.listontimeout [as ontimeout] (timers.js:112:15)  finished in 0.255 seconds 1 test, 2 assertions, 1 failure, 0 skipped 

thanks!

i fixed using .after() instead .afterjson().


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -