Witam przy parsowaniu obiektu JSON wywala mi cały czas błędy. Nie wklejam tutaj JSON'a bo nic tam nie jest źle...
Błędy zaczeły się pojawiać gdy zrobiłem takie coś:
Bez tej zmiennej req.query.server było wszystko git!
case 'fightClose': {
var fightCloseOp = {
url: 'http://'+req.query.server+'.margonem.pl/engine?t=fight&a=quit&town_id='+req.query.map+'&ev='+req.query.ev+'&mobile_token='+md5('humantorch-' + req.query.token)+'&mobile=1',
headers: {
"Cookie": req.query.cookie,
"Origin": "http://"+req.query.server+".margonem.pl/",
"Referer": "http://"+req.query.server+".margonem.pl/",
"Connection": "Keep-Alive",
"User-Agent": "Dalvik/1.6.0 (Linux; U; Android 4.4.2; GT-I9500 Build/KOT49H)"
}
}
}
request.get(fightCloseOp, (err, response, body) => {
// WYSLIJ DO KLIENTA!!!!!!!!!
res.send({fight: body});
});
break;
Uncaught SyntaxError: Unexpected token o in JSON at position 1
at Function.parse [as parseJSON] (<anonymous>)
at Object.$.get [as success] (name.js:102)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)