0

I want to pass an object as a Url Parameter and then get it from the next page. Object is from Youtube api.

The object is I'm getting like this....

    {
    "kind": "youtube#video",
    "etag": "XOQN_sO_2TKRU7Yqu7M3wBlraQs",
    "id": "WKjZlozgHh8",
    "snippet": {
        "publishedAt": "2022-04-19T07:05:01Z",
        "channelId": "UCoxEmfaNM9eCqIER5KnjPxg",
        "title": "Allah humare Maa Baap ko salamat rakhe❤. #shorts #hearttouching #shadab707 #ramadan #humanity",
        "description": "",
        "thumbnails": {
            "default": {
                "url": "https://i.ytimg.com/vi/WKjZlozgHh8/default.jpg",
                "width": 120,
                "height": 90
            },
            "medium": {
                "url": "https://i.ytimg.com/vi/WKjZlozgHh8/mqdefault.jpg",
                "width": 320,
                "height": 180
            },
            "high": {
                "url": "https://i.ytimg.com/vi/WKjZlozgHh8/hqdefault.jpg",
                "width": 480,
                "height": 360
            },
            "standard": {
                "url": "https://i.ytimg.com/vi/WKjZlozgHh8/sddefault.jpg",
                "width": 640,
                "height": 480
            },
            "maxres": {
                "url": "https://i.ytimg.com/vi/WKjZlozgHh8/maxresdefault.jpg",
                "width": 1280,
                "height": 720
            }
        },
        "channelTitle": "shadab5star",
        "categoryId": "24",
        "liveBroadcastContent": "none",
        "defaultLanguage": "hi",
        "localized": {
            "title": "Allah humare Maa Baap ko salamat rakhe❤. #shorts #hearttouching #shadab707 #ramadan #humanity",
            "description": ""
        },
        "defaultAudioLanguage": "hi"
    },
    "statistics": {
        "viewCount": "27358358",
        "likeCount": "2117651",
        "favoriteCount": "0",
        "commentCount": "2297"
    },
    "channelThumbnail": "https://yt3.ggpht.com/-zSVV-QiSnUzyKrnb2UgnJxpfm9v4FIjVJ-hIluSnp-8GqRgyQgI0mJv1twrI9hsU3_p44hU=s88-c-k-c0x00ffffff-no-rj"
}

Then I want to go the next page.

<div class="video-container" onClick="location.href = 'playingvideo.html?id=${data}'">

Then get the object data but i can't do it's give me [object, object].

function getUrlParams( parameterName ){
let parameters = new URLSearchParams(window.location.search)
return parameters.get( parameterName); }


var id = getUrlParams("id");
  • That's *a lot* of data to put on a URL. You could JSON-encode it, then perhaps Base64-encode (or at least URL-encode) it. But it's far more common to include in the URL only an identifier of some kind and use that identifier to fetch the data on the subsequent page. Why do you need to pass an entire complex object on a URL? – David Apr 25 '22 at 13:27

0 Answers0