TypeError: str.trim is not a function (Request-Promise/Tough-Cookie)

3.8k Views Asked by At

I am having similar problem as discussed here: https://github.com/request/request-promise/issues/183

I am using [email protected] and [email protected]

And getting the same error:

TypeError: str.trim is not a function

I also played around with npm-dedupe

enter image description here

Any clue,

My code looks like this:

let cookie = new tough.Cookie({domain: '.companyName.ninja',
  httpOnly: true,
  name: '_application_session',
  path: '/',
  secure: false,
  value: 'f044888d39e2d19126716d9f54028700' })
let cookieJar = request.jar()
cookieJar.setCookie(cookie, 'http://application.companyName.ninja/')
options.jar = cookieJar
1

There are 1 best solutions below

0
On

Change line

cookieJar.setCookie(cookie, 'http://application.companyName.ninja/')

to

cookieJar.setCookie(cookie.toString(), 'http://application.companyName.ninja/') 

(use toString() method).