Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
how i get the value from the first url and pass that value to second url parameter?

I am new to learn express. i try to get the value from the first url and pass that value to second url parameter?

router.get('/',  function(req, res, next){

const teamId = ''
var player_data = {
method: 'GET',
url: 'https://sofascore.p.rapidapi.com/teams/get-player-statistics',
params: {teamId: '', tournamentId: '7', seasonId: '29267', type: 'overall'},
};

axios.request(team_data)
  .then(function (response) {
    const teamId = response.data.teams[0].id
    console.log(teamId)
    //axios.request(player_data)
    //   .then(function (response){
    //     const players = response.topPlayers.goals
    //     res.render('index',{players: players})
    //   })
     })          
})

the output

 [nodemon] restarting due to changes...
 [nodemon] starting `node ./bin/www`
 [nodemon] restarting due to changes...
 [nodemon] starting `node ./bin/www`
 3427

it returns that team to me correctly, but why I pass the id to second url to get team member nothing there?

output
    params: {
    teamId: '',
    tournamentId: '7',
    seasonId: '29267',
    type: 'overall'
  },

  ....
           'user-agent': [ 'User-Agent', 'axios/0.21.4' ],
    host: [ 'Host', 'sofascore.p.rapidapi.com' ]
  }
},
data: '400 - Bad Request'
},
 isAxiosError: true,
  toJSON: [Function: toJSON]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to put teamId into the player_data.params object.

axios.request(team_data)
  .then(function(response) {
    const teamId = response.data.teams[0].id
    console.log(teamId)
    player_data.params.teamId = teamId
    axios.request(player_data)
      .then(function(response) {
        const players = response.topPlayers.goals
        res.render('index', {
          players: players
        })
      })
  })
})

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!