Use Axios.Get with params and config together

前端 未结 2 1958
执笔经年
执笔经年 2021-01-01 05:36

How do I use axios.get with params and config together? My code is not working. Please help me this basic issue!

let config = {
    \'headers\':         


        
2条回答
  •  余生分开走
    2021-01-01 06:03

    Axios takes the entire config in the second argument, not a list of config objects. Put the params inside the config, and pass the entire object as the second argument:

    let f = 0
    
    let config = {
      headers: {'Authorization': 'JWT ' + this.$store.state.token},
      params: {
        page: f + 1
      },
    }
    
    axios.get('http://localhost:8000/api/v1/f/', config)

提交回复
热议问题