国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

vue調(diào)用delete的接口后,再調(diào)用列表post接口,返回400 Bad Request

康康

問題描述

后臺(tái)單個(gè)列表,點(diǎn)擊刪除按鈕之后調(diào)用webman寫的接口,delete請(qǐng)求方式,然后接口返回成功,成功后前端新請(qǐng)求列表接口并刷新列表,請(qǐng)求的列表接口報(bào) 400 Bad Request

程序代碼

      // 刪除模版
      deleteTemp(item) {
        this.$confirm('此操作將刪除該模版, 是否繼續(xù)?', '提示', {
          confirmButtonText: '確定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http.delete(`/api/report/template/${item.template_no}`).then(
            response => {
              let res = response.body;
              if (res.error_code === 0) {
                this.isLoading = false;
                this.$notify({
                  title: "刪除成功",
                  message: res.message,
                  type: "success",
                  duration: 1000
                });
                this.onChangePage();
              } else {
                this.isLoading = false;
                this.$notify({
                  title: "提示",
                  message: res.message,
                  type: "warning",
                  duration: 1000
                });
              }
            },
            response => {
              response &&
                this.$notify({
                  title: "提示",
                  message: response,
                  type: "error",
                  duration: 1000
                });
            }
          );
        }).catch((err) => {});
      },

在onChangePage方法中會(huì)調(diào)用列表接口, 使用的 this.$http.post 接口返回了400

報(bào)錯(cuò)信息

400 Bad Request
發(fā)現(xiàn)把刪除的接口換成非delete(如使用post或者get)之后就沒問題了,但delete之后的請(qǐng)求會(huì)400,但刷新單獨(dú)請(qǐng)求列表就能正常響應(yīng)。把delete請(qǐng)求發(fā)送到其他服務(wù)上驗(yàn)證,也是沒有問題的。
正常的返回:
截圖

截圖報(bào)錯(cuò)信息里報(bào)錯(cuò)文件相關(guān)代碼

截圖

操作系統(tǒng)及workerman/webman等框架組件具體版本

openresty/1.21.4.1
Webman-framework v1.4.7
PHP 7.4.30

1342 1 0
1個(gè)回答

walkor 打賞

可能是你的delete請(qǐng)求不符合HTTP協(xié)議,比如delete請(qǐng)求包含了body。
升級(jí)workerman試下,新版workerman對(duì)delete帶body的情況作了兼容

  • 康康 2023-03-30

    好,關(guān)鍵是delete請(qǐng)求是正常的,但后續(xù)的post請(qǐng)求失敗了。

  • walkor 2023-03-30

    正常delete不會(huì)有body,所以body不會(huì)被讀取仍然留在socket緩沖區(qū),下次請(qǐng)求會(huì)把這個(gè)body當(dāng)作http頭,所以報(bào)錯(cuò)400

年代過于久遠(yuǎn),無法發(fā)表回答
??