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
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
If we call the trim () method on the value that is not of a string type, JavaScript will throw a TypeError: trim is not a function. In this tutorial, we will look at what is TypeErrror: trim is not a function error and how to resolve them with examples. What is TypeError: trim is not a function error?
But it displays error TypeError: string.trim is not a function. Please help why is this so. const isEmpty = (string) => { if (string.trim () === '') return true; else return false; }; This is to check the whether a string is empty or not. I'm making a react project with firebase. Are you sure string is a string?
Also why not just string => string.trim () === ''? Yes.. String is a string. I don't know what causing up the problem. Well e.g. "".trim will tell you it is a function, so either string isn't a string or you're on some pre-ES5 runtime that doesn't have the method.
If the value is a string, we return the result of calling the trim method, otherwise we return an empty string for consistency. If you want to trim all strings in an array, use the map method to iterate over the array and call the trim method on each string. The map method takes a function and calls it with each element in the array.
Change line
cookieJar.setCookie(cookie, 'http://application.companyName.ninja/')
to
cookieJar.setCookie(cookie.toString(), 'http://application.companyName.ninja/')
(use toString()
method).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With