У меня есть большой глубоко вложенный объект JS, который отправляется на сервер Express. js после того, как он получает JSON .strify () и превращает его в строку. Я попробовал то же самое с меньшим и мелко вложенным объектом, затем он работал нормально.
Вот большой объект:
{
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'
]
]
}
Вот код в 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);
});
Я получаю ошибку:
<code>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
Вот строка:
{"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"]]}