hello, im working on this code here
const teams = [ { team: 'Arsenal', id: 'ars', address: 'https://www.marca.com/en/football/arsenal.html', base: '' }, { team: 'CF Chelsea', id: 'chl', address: 'https://www.marca.com/en/football/chelsea.html', base: '' }, { team: 'Liverpool', id: 'lvr', address: 'https://www.marca.com/en/football/liverpool.html', base: '' }, { team: 'Manchester City', id: 'mnc', address: 'https://www.marca.com/en/football/manchester-city.html', base: '' }, { team: 'Manchester United', id: 'mnu', address: 'https://www.marca.com/en/football/manchester-united.html', base: '' } ]
this is a list of teams, the problem is that this is just a sample … the actual list have more than 100 teams. i want the create a “teamList.js” file and import it to my main file “index.js” because i want to make it well organized and not too long, then call it here …
app.get('/teams/:teamId', (req, res) => {
const teamId = req.params.teamId
const teamAddress = teams.filter(team => team.id == teamId)[0].address
const teamBase = teams.filter(team => team.id == teamId)[0].base
const teamName = teams.filter(team => team.id == teamId)[0].team
how to do that? and i really appreciate it.