Social-Club-example-parser icon indicating copy to clipboard operation
Social-Club-example-parser copied to clipboard

TypeError: Cannot read property 'replace' of undefined

Open Mo45 opened this issue 8 years ago • 7 comments

root@playplanet:/home/mo45/scp# node index.js Mo45UA Checking for existing cookies and verification token Existing cookies and verification token found Send GET-request to: http://socialclub.rockstargames.com/games/gtav/career/overviewAjax?character=Freemode&nickname=Mo45UA&slot=Freemode&gamerHandle=&gamerTag=&_=1485856587832 /home/mo45/scp/index.js:136 return parseInt(input.replace(/[$,]/g, '').trim()); ^

TypeError: Cannot read property 'replace' of undefined at parseInteger (/home/mo45/scp/index.js:136:26) at Request._callback (/home/mo45/scp/index.js:428:29) at Request.self.callback (/home/mo45/scp/node_modules/request/request.js:186:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (/home/mo45/scp/node_modules/request/request.js:1081:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at Gunzip. (/home/mo45/scp/node_modules/request/request.js:1001:12) at Gunzip.g (events.js:291:16)

Node version 6.9.2

When trying to npm install get this: npm WARN [email protected] No repository field. After that i install required modules by myself. but still have same error.

Mo45 avatar Jan 31 '17 08:01 Mo45

I don't think there is a problem with the modules. My guess is that the input variable is empty, thus the replace() is failing.

Maybe try to remove the cookie jar and run again?

frdmn avatar Feb 02 '17 18:02 frdmn

I removed the cookie jar, and completely reinstalled script in another directory. Still dont work for me.

Existing cookies and verification token found

Mo45 avatar Feb 02 '17 18:02 Mo45

Are you familiar with Node and able to add some debug statements? I would try to console.log() the input in the parseInteger() function and maybe also something to figure out which one of the executions (of parseInteger()) fails exactly.

frdmn avatar Feb 02 '17 18:02 frdmn

Here it is, line 135-136 of index.js with parseInteger function. What i need to do with it?

function parseInteger(input) { return parseInt(input.replace(/[\$,]/g, '').trim()); }

Mo45 avatar Feb 03 '17 06:02 Mo45

First, try something like this:

/**
 * Parse a string to an integer, including stripping the 'per mille' sign (,) and the dollar sign ($).
 * @param {string} input - The input to be parsed to an integer.
 * @returns {number} - The parsed integer.
 */
function parseInteger(input) {
    console.log(input);
    return parseInt(input.replace(/[\$,]/g, '').trim());
}

frdmn avatar Feb 11 '17 13:02 frdmn

root@playplanet:/home/mo45/scp# node index.js Mo45UA Checking for existing cookies and verification token Existing cookies and verification token found Send GET-request to: http://socialclub.rockstargames.com/games/gtav/career/overviewAjax?character=Freemode&nickname=Mo45UA&slot=Freemode&gamerHandle=&gamerTag=&_=1487435029365 undefined /home/mo45/scp/index.js:137 return parseInt(input.replace(/[$,]/g, '').trim()); ^

TypeError: Cannot read property 'replace' of undefined at parseInteger (/home/mo45/scp/index.js:137:26) at Request._callback (/home/mo45/scp/index.js:429:29) at Request.self.callback (/home/mo45/scp/node_modules/request/request.js:186:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (/home/mo45/scp/node_modules/request/request.js:1081:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at Gunzip. (/home/mo45/scp/node_modules/request/request.js:1001:12) at Gunzip.g (events.js:291:16) root@playplanet:/home/mo45/scp#

Mo45 avatar Feb 18 '17 16:02 Mo45

Can you log into Socialclub, open this URL in your browser and give me the full output? (Right click, show source, paste here)

frdmn avatar Feb 20 '17 07:02 frdmn