第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

axios delete .catch 命令在 void 中不存在

axios delete .catch 命令在 void 中不存在

catspeake 2021-11-25 16:50:13
我一直在嘗試使用 axios .delete 請(qǐng)求從列表中刪除卡片。刪除函數(shù)的代碼如下:deleteProduct(id: any) {    const { adminhelpcard } = this.state;    const apiVideoUrl = `http://localhost:3000/videos/${id}`;    //const apiManualUrl = `http://localhost:3000/manuals/${id}`;    const options = {      method: "DELETE"    };    axios      .delete(apiVideoUrl, {})      .then((response: any) => {        this.setState({          adminhelpcard: adminhelpcard.filter((adminhelpcard: SingleAdminHelpCard) => adminhelpcard.id !== id)        }).catch(function(error) {          console.log(error);        });我從 .catch 和函數(shù)(錯(cuò)誤)中收到兩個(gè)不同的錯(cuò)誤。.catch 的錯(cuò)誤是:Property 'catch' does not exist on type 'void'.ts(2339)來自 (error) 的錯(cuò)誤是:Parameter 'error' implicitly has an 'any' type.ts(7006)有什么我顯然錯(cuò)過了嗎?提前感謝您的時(shí)間和幫助。
查看完整描述

2 回答

?
瀟瀟雨雨

TA貢獻(xiàn)1833條經(jīng)驗(yàn) 獲得超4個(gè)贊

您正在嘗試catch你的setState電話,而不是刪除請(qǐng)求本身:


axios

      .delete(apiVideoUrl, {})


      .then((response: any) => {

        this.setState({

          adminhelpcard: adminhelpcard.filter((adminhelpcard: SingleAdminHelpCard) => adminhelpcard.id !== id)

        })

       }).catch(function(error) {

          console.log(error);

        });


查看完整回答
反對(duì) 回復(fù) 2021-11-25
?
白衣非少年

TA貢獻(xiàn)1155條經(jīng)驗(yàn) 獲得超0個(gè)贊

您將 .catch() 附加到 setState() 而不是 .then()


改變:


axios

      .delete(apiVideoUrl, {})


      .then((response: any) => {

        this.setState({

          adminhelpcard: adminhelpcard.filter((adminhelpcard: SingleAdminHelpCard) => adminhelpcard.id !== id)

        }).catch(function(error) {

          console.log(error);

        });

到:


axios


   .delete(apiVideoUrl, {})

   .then((response:any) => {

        this.setState({

            adminhelpcard: adminhelpcard.filter((adminhelpcard: SingleAdminHelpCard) => adminhelpcard.id !== id)

        })

    }).catch(function(error) {

        console.log(error);

    });


查看完整回答
反對(duì) 回復(fù) 2021-11-25
  • 2 回答
  • 0 關(guān)注
  • 629 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)