Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Mo45 opened this issue Jan 31, 2017 · 7 comments
Open

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

Mo45 opened this issue Jan 31, 2017 · 7 comments

Comments

@Mo45
Copy link

Mo45 commented Jan 31, 2017

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 Mo45 changed the title TypeError: Cannot read property 'trim' of undefined TypeError: Cannot read property 'replace' of undefined Jan 31, 2017
@frdmn
Copy link
Member

frdmn commented Feb 2, 2017

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
Copy link
Author

Mo45 commented Feb 2, 2017

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

Existing cookies and verification token found

@frdmn
Copy link
Member

frdmn commented Feb 2, 2017

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
Copy link
Author

Mo45 commented Feb 3, 2017

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
Copy link
Member

frdmn commented Feb 11, 2017

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
Copy link
Author

Mo45 commented Feb 18, 2017

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
Copy link
Member

frdmn commented Feb 20, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants