Vue-cli scaffolding builds pages, and axios asks how to request api, with parameters.

scaffolding built with vue-cli,

now there is api, but he has a parameter
{"CatId": 238, "Similar": false, "Trend": false, "IsNew": false, "Sales": true, "SuppNo": "LKN", "SuppCatId": 0}
http://116.62.33.192:66/product/getproductdetaillist

write as axion on the Internet. I don"t know where to write the parameters.

"/api": {
                target:"http://116.62.33.192:66/product/getproductdetaillist",
                changeOrigin:true, 
                pathRewrite:{
                    "^/api": "/api"
                }
            }
            
            
let postData = {"CatId": 238, "Similar": false, "Trend": false, "IsNew": false, "Sales": true, "SuppNo": "LKN", "SuppCatId": 0}
export default {
  methods: {
    jsonpData: function () {
      this.$axios.post("/api", postData)
        .then(res => {
          console.log(res)
        })
        .catch(err => {
          console.log(err)
        })
    }
  }
}

write this way, he says 404, if you don"t, he says 405.

Mar.18,2021

if it is a get request, axios.get ('interface address', {params: {passed parameter}})

if it is a post request .axios.post ('interface address', the parameter object representation passed)


try Post and Get, or other methods for request

Menu