The problem of passing parameters in vue axios

the front end needs to pass two parameters to the backend, one id, and one type,. I encapsulated these two parameters into an object and each time the id failed to pass. If it is not encapsulated, how can I pass the two parameters to the backend (the id comes from I click on a line of a table and the id,type is the defined type)

Jun.02,2021

Let's take a look at the specific code


only id failed? Did you click to get id


in this way, if it is a get request:

const params = {
  id:id,
  type:type  
}
axios.get('api',{params}).then((res)=>{
},(err)=>{
})

if it is a post request:

const params = {
  id:id,
  type:type  
}
axios.get('api',params).then((res)=>{
},(err)=>{
})
Menu