1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Store data in Local Storage from JSON file

Discussion in 'JavaScript' started by ManpreetWeb, Sep 16, 2020.

  1. #1
    I am trying to store data in the local Storage from my JSON file. But I am getting an empty array in the local Storage. File name is 'data' in the project.
    [
    "friends": [
    {
    "id": 0,
    "name": "Daugherty Gould"
    },
    {
    "id": 1,
    "name": "Foley Carpenter"
    },
    {
    "id": 2,
    "name": "Brewer Vinson"
    }
    ]
    SEMrush
    localStorage.setItem('firstName',data.friends.name );

    I am not getting the right output with above code. How can I get all the names in localstorage.

    Thank you in advance!
     
    ManpreetWeb, Sep 16, 2020 IP
    SEMrush