I have an object that looks like this:
const mappings = {
greeting: {
'en': [
'Hello',
'Hi',
'Hey'
],
'it': [
'Ciao',
'Buongiorno',
'Buonasera'
]
}
}
Based on the language in the query, I would like to pick that language up.
So I tried const language = req.query.language
which can be it
or en
. But when I try to return Hello or Ciao mappings.greeting.language[0]
it does not return anything, because it doesn't pick up the variable language
.
How can I pass the variable in my query?