v2.5.0 : str.trim() is not a function
See original GitHub issueWe’re using tough-cookie ^2.4.3 (which actually installs 2.5.0) with request ^2.88.0.
This code worked with 2.4.3 :
const cookiesJar = requestModule.jar();
_.forEach(initialCookies, (cookie: Object) => {
const newCookie = toughCookie.fromJSON(JSON.stringify(cookie));
const hostUrl = `${initialOptions.protocol}//${initialOptions.host}/`;
cookiesJar.setCookie(newCookie, hostUrl);
});
But we’re getting the following error with 2.5.0 :
TypeError: str.trim is not a function
at Function.parse (node_modules/request/node_modules/tough-cookie/lib/cookie.js:429:13)
at CookieJar.setCookie (node_modules/request/node_modules/tough-cookie/lib/cookie.js:1011:21)
at CookieJar.setCookieSync (node_modules/request/node_modules/tough-cookie/lib/cookie.js:1402:18)
at RequestJar.setCookie (node_modules/request/lib/cookies.js:25:20)
Any hint about what could cause this issue in 2.5.0?
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:15
- Comments:24 (10 by maintainers)
Top Results From Across the Web
[Solved] TypeError: trim is not a function - ItsJavaScript
The TypeError: trim is not a function occurs if we call a trim() method on the value that is not of a type...
Read more >TypeError: trim is not a function in JavaScript | bobbyhadz
The "trim is not a function" error occurs when we call the trim() method on a value that is not a string. To...
Read more >javascript - .trim() is not a function - Stack Overflow
Even if you start with a string instead of an array then the split method returns an array and there is no trim...
Read more >String.prototype.trim() - JavaScript - MDN Web Docs
The trim() method removes whitespace from both ends of a string and returns a new string, without modifying the original string.
Read more >String.Trim Method (System) - Microsoft Learn
Returns a new string in which all leading and trailing occurrences of a set of specified characters from the current string are removed....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
typescript
(cookie instanceof Cookie)
return false.@awaterma
workaround
I’m still seeing this with v3.0.1.