Home > Software design >  Nodejs creating dictionary with multiple values error
Nodejs creating dictionary with multiple values error

Time:10-27

I am trying to create a dictionary for verified addresses. But I am getting an error. How do I fix this?

SyntaxError: Unexpected token '{'

const Addresses = {
    {
        "0x0000000000000000000000000000000000000000": "BURN", 
        "Verified": "Yes"
        "Type": "Address"
    },
    {
        "0x1010101010101010101010101010101010101010": "BURN", 
        "Verified": "No"
        "Type": "Address"
    }
}

CodePudding user response:

You need to update the variable type from json to object and add commas. so like this.

const Addresses = [
    {
        "0x0000000000000000000000000000000000000000": "BURN", 
        "Verified": "Yes",
        "Type": "Address"
    },
    {
        "0x1010101010101010101010101010101010101010": "BURN", 
        "Verified": "No",
        "Type": "Address"
    }
]

{ ... } => [ ... ]

... : "Yes",

... : "No",

CodePudding user response:

I believe you left out 2 commas resulting in a syntax error

const Addresses = {
    {
        "0x0000000000000000000000000000000000000000": "BURN", 
        "Verified": "Yes",
        "Type": "Address"
    },
    {
        "0x1010101010101010101010101010101010101010": "BURN", 
        "Verified": "No",
        "Type": "Address"
    }
}

(added commas after "Yes" and "No")
  • Related