gta5-map / Social-Club-example-parser

Simple example parser for Rockstar's Social Club written in PHP
MIT License
29 stars 13 forks source link

TypeError: Cannot read property 'replace' of undefined #13

Open Mo45 opened 7 years ago

Mo45 commented 7 years ago

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 socialclubparser@1.4.0 No repository field. After that i install required modules by myself. but still have same error.

frdmn commented 7 years ago

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?

Mo45 commented 7 years ago

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

Existing cookies and verification token found

frdmn commented 7 years ago

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.

Mo45 commented 7 years ago

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()); }

frdmn commented 7 years ago

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());
}
Mo45 commented 7 years ago

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#

frdmn commented 7 years ago

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