0

I have a big deeply nested JS object that is send to the Express.js server after it gets JSON.strify() and turned it into an string. I tried the same thing with a smaller and shallowly nested object, then it worked fine.

Here's the big object:

{
      channelName: 'PewDiePie',
      channelTag: 'UC-lHJZR3Gqxm24_Vd_AJ5Yw',
      channelLogoLink: 'https://yt3.ggpht.com/a/AATXAJzlZzr16izsGHBCHIkO3H7n-UiHyZPCJFEPiQ=s88-c-k-c0xffffffff-no-rj-mo',
      unseenVideoTitles: [
        [
          'I Made The WORST Minecraft MISTAKE There Is. .. - Part 40',
          'The MOST Dangerous Place In Minecraft!',
          'I Found The New Biome in Minecraft! (Nether Update)',
          'I\'m Back in Minecraft! - Part 39'
        ]
      ],
      videoThumbnailLinks: [
        [
          'https://i.ytimg.com/vi/8HHZiNdrZGA/mqdefault.jpg',
          'https://i.ytimg.com/vi/evcMQ7Lk8NU/mqdefault.jpg',
          'https://i.ytimg.com/vi/aOXAtnb-grk/mqdefault.jpg',
          'https://i.ytimg.com/vi/1B1f9PGLbIs/mqdefault.jpg'
        ]
      ],
      videoLinks: [
        [
          'https://www.youtube.com/watch?v=8HHZiNdrZGA',
          'https://www.youtube.com/watch?v=evcMQ7Lk8NU',
          'https://www.youtube.com/watch?v=aOXAtnb-grk',
          'https://www.youtube.com/watch?v=1B1f9PGLbIs'
        ]
      ],
      videoUploadTime: [
        [
          '2020-03-13',
          '2020-03-31',
          '2020-03-25',
          '2020-03-06'
        ]
      ]
    }

Here's the code in Express.js:

router.get('/query/:stringifiedObj', (req, res) => {
  const retrievedObj = JSON.parse(req.params.stringifiedObj);
  const uid = retrievedObj.uid;
  delete retrievedObj.uid;
  console.log(uid, retrievedObj);
  res.status(200).send(uid);
});

The error I get is:

HTTP/1.1 404 Not Found
X-Powered-By: Express
Content-Security-Policy: default-src 'none'
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Content-Length: 955
Date: Sat, 04 Apr 2020 11:42:17 GMT
Connection: close

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /api/query/%7B%22channelName%22:%22PewDiePie%22,%22channelTag%22:%22UC-lHJZR3Gqxm24_Vd_AJ5Yw%22,%22channelLogoLink%22:%22https://yt3.ggpht.com/a/AATXAJzlZzr16izsGHBCHIkO3H7n-UiHyZPCJFEPiQ=s88-c-k-c0xffffffff-no-rj-mo%22,%22unseenVideoTitles%22:[[%22I%20Made%20The%20WORST%20Minecraft%20MISTAKE%20There%20Is.%20..%20-%20Part%2040%22,%22The%20MOST%20Dangerous%20Place%20In%20Minecraft!%22,%22I%20Found%20The%20New%20Biome%20in%20Minecraft!%20(Nether%20Update)%22,%22I%27m%20Back%20in%20Minecraft!%20-%20Part%2039%22]],%22videoThumbnailLinks%22:[[%22https://i.ytimg.com/vi/8HHZiNdrZGA/mqdefault.jpg%22,%22https://i.ytimg.com/vi/evcMQ7Lk8NU/mqdefault.jpg%22,%22https://i.ytimg.com/vi/aOXAtnb-grk/mqdefault.jpg%22,%22https://i.ytimg.com/vi/1B1f9PGLbIs/mqdefault.jpg%22]],%22videoLinks%22:[[%22https://www.youtube.com/watch</pre>
</body>
</html>

Here's the string:

{"channelName":"PewDiePie","channelTag":"UC-lHJZR3Gqxm24_Vd_AJ5Yw","channelLogoLink":"https://yt3.ggpht.com/a/AATXAJzlZzr16izsGHBCHIkO3H7n-UiHyZPCJFEPiQ=s88-c-k-c0xffffffff-no-rj-mo","unseenVideoTitles":[["I Made The WORST Minecraft MISTAKE There Is. .. - Part 40","The MOST Dangerous Place In Minecraft!","I Found The New Biome in Minecraft! (Nether Update)","I'm Back in Minecraft! - Part 39"]],"videoThumbnailLinks":[["https://i.ytimg.com/vi/8HHZiNdrZGA/mqdefault.jpg","https://i.ytimg.com/vi/evcMQ7Lk8NU/mqdefault.jpg","https://i.ytimg.com/vi/aOXAtnb-grk/mqdefault.jpg","https://i.ytimg.com/vi/1B1f9PGLbIs/mqdefault.jpg"]],"videoLinks":[["https://www.youtube.com/watch?v=8HHZiNdrZGA","https://www.youtube.com/watch?v=evcMQ7Lk8NU","https://www.youtube.com/watch?v=aOXAtnb-grk","https://www.youtube.com/watch?v=1B1f9PGLbIs"]],"videoUploadTime":[["2020-03-13","2020-03-31","2020-03-25","2020-03-06"]]}
Evading Shadows
  • 479
  • 1
  • 6
  • 22
  • 1
    dont do over get request [What is the maximum length of a URL in different browsers?](https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers) – Lawrence Cherone Apr 04 '20 at 11:48
  • if your only after `uid`, then just send that :/ – Lawrence Cherone Apr 04 '20 at 11:50
  • @LawrenceCherone But the object that I am sending is only 900 character long(after strigified), which is way below the limit of 2,000 character. – Evading Shadows Apr 04 '20 at 12:28
  • @LawrenceCherone No I am not only after uid. I need the retrievedObj as I will be processing it. (I removed that part of the code for simplicity) – Evading Shadows Apr 04 '20 at 12:31

0 Answers0