current position:Home>About Axios request - delete method

About Axios request - delete method

2022-06-24 08:33:37User 2323866

Some people only know delete Method , When transferring values , Put the request value in url On , And like post Methods those , With request body , But I don't know how to transfer values .

First ,delete There are three ways to write the method

One : The request parameters are spliced in url On

  axios.delete('/delete', {	
      params: {	//  The request parameters are spliced in url On 
        id: 12
      }
    }).then(res => {
      console.log(res)
    })

Two : The request parameters are placed in the request body

axios.delete('/delete', {	
      data: {	//  The request parameters are placed in the request body 
        id: 12
      }
    }).then(res => {
      console.log(res)
    })

3、 ... and : The request parameters are spliced in url Or request parameters on the request body

axios({
      method: 'delete',
      url: '/delete',
      params: {}, //  The request parameters are spliced in url On 
      data: {}  //  The request parameters are placed in the request body 
    }).then(res => {
      console.log(res)
    })

copyright notice
author[User 2323866],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/175/20210623184250965m.html

Random recommended