8

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

I am using Request-Promise@4.2.2 and Tough-Cookie@2.3.4

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
Kapil Chokhawala
  • 196
  • 2
  • 10
  • 1
    You might want to try request-promise-native@1.0.5? I have it working with tough-cookie@2.3.4 (even when request-promise, which uses Bluebird instead of native promises, still is broken) – jlmcdonald Jun 13 '18 at 16:26
  • Are you missing the key when creating the Cookie? – AAlferez Jul 18 '18 at 19:17

1 Answers1

14

Change line

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

to

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

(use toString() method).

kmaci
  • 3,094
  • 2
  • 18
  • 28