鍍金池/ 問答/Linux  HTML/ json-server中使用RESTFUL API如何實(shí)現(xiàn)批量刪除

json-server中使用RESTFUL API如何實(shí)現(xiàn)批量刪除

在使用vue做后臺(tái)管理的系統(tǒng)的時(shí)候,會(huì)有批量刪除的操作,但是在找了很多資料之后仍然無法解決,希望得到大家的幫助。

axios({
  method: 'delete',
  url: that.baseURL,
    params: {
      id: [1,2]
    },
  headers: {'Content-Type': 'application/json'},
  responseType: 'json'
}).then(function (response) {
  console.log(response)
}).catch((error) => console.log(error))

當(dāng)URL設(shè)置為thatbaseURL/id時(shí)是可以刪除數(shù)據(jù)的,設(shè)置params為id:1也是無法刪除數(shù)據(jù)的,會(huì)報(bào)如下錯(cuò),是delete不支持設(shè)置params嗎?
圖片描述
附server.js部分配置:

server.use(jsonserver.rewriter({
  '/api/': '/',
  '/api/users': '/users',
  '/api/users/:id': '/users/:id',
  '/api/users\\?id=:id': '/users/:id'
}))

如果大家發(fā)現(xiàn)什么錯(cuò)誤,或者有什么建議,希望可以予以指點(diǎn)!

回答
編輯回答
你好胸

/api/users\\?id=:id改成/api/users?id=:id試試

2017年6月11日 18:03