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

1

8

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
Absently answered 25/5, 2018 at 0:4 Comment(2)
You might want to try [email protected]? I have it working with [email protected] (even when request-promise, which uses Bluebird instead of native promises, still is broken)Pretension
Are you missing the key when creating the Cookie?Bollay
A
14

Change line

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

to

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

(use toString() method).

Antiperiodic answered 27/5, 2019 at 19:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.