Reactjs 谷歌应用程序脚本&;React.js:删除https://mygoogleappapi.com/exec 405(方法不允许)

Reactjs 谷歌应用程序脚本&;React.js:删除https://mygoogleappapi.com/exec 405(方法不允许),reactjs,google-apps-script,axios,rowdeleting,google-apps-script-web-application,Reactjs,Google Apps Script,Axios,Rowdeleting,Google Apps Script Web Application,谢谢你的阅读! 我现在正在学习如何使用汽油, 我无法删除我在google电子表格上选择的特定行。 当我使用react应用程序和google脚本api时,尝试使用“axios.delete方法”删除时,我遇到了主题错误 我已经使用axios通过了GET方法和POST方法。实际上,我可以从我的谷歌电子数据表中获取并发布我的数据 但是删除无法很好地访问 我发现这个错误405是不允许访问我的谷歌工作表的,但为什么我可以得到这个错误,即使post方法是可访问的 我的应用程序脚本或react.js代码需要其

谢谢你的阅读! 我现在正在学习如何使用汽油, 我无法删除我在google电子表格上选择的特定行。 当我使用react应用程序和google脚本api时,尝试使用“axios.delete方法”删除时,我遇到了主题错误

我已经使用axios通过了GET方法和POST方法。实际上,我可以从我的谷歌电子数据表中获取并发布我的数据

但是删除无法很好地访问

我发现这个错误405是不允许访问我的谷歌工作表的,但为什么我可以得到这个错误,即使post方法是可访问的

我的应用程序脚本或react.js代码需要其他代码吗?我解决不了这个问题。。。 我想解决此错误并删除我选择的特定行。另外,我想知道这个错误的解决方法。 你知道吗?如果你有什么好主意,能告诉我吗

谢谢你的阅读

这是我的应用程序脚本代码

function doDelete(req, sheet) {
   var id = req.parameter.id;

   var Row = sheet.getLastRow();
   for (var i = 1; i <= Row; i++) {
      var idTemp = sheet.getRange(i, 1).getValue();
      if (idTemp == id) {
         sheet.deleteRow(i);
      }

   }

} 

function-doDelete(要求,表格){
var id=req.parameter.id;
var Row=sheet.getLastRow();
对于(var i=1;i{
axios.get(api)
。然后((res)=>{
console.log(res.data)
这是我的国家({
信息:资源数据
})
})
}
//访问帖子!
createInfo=()=>{
axios.post(api{
产品:“霍格”,
价格:1000,
小型停车场:1000,
卡通化:“40*30*50”
},optionAxios)
。然后((res)=>{
这个.getInfo(res);
})
}
//无法访问删除!
deleteInfo=(e)=>{
控制台日志(e);
删除(api{
id:e,
},optionAxios)
。然后((res)=>{
这个.getInfo(res);
console.log('success!');
})
}
render(){
返回(
createButon
{this.state.info.map(info=>
{info.product}
this.deleteInfo(info.id)}>×
)}
);
}
}
出口违约价格;
试试这个:

function doDelete(req, sh) {
  var id = req.parameter.id;
  const ss=SpreadsheetApp.getActive();
  sh=sh||ss.getActiveSheet();
  var vs=sh.getRange(1,1,sh.getLastRow(),1).getValues();
  var d=0;
  for (var i=0;i<vs.length;i++) {
    if (vs[i][0]== id) {
      sh.deleteRow(i+1-d++);
    }
  }
} 
函数doDelete(请求,sh){
var id=req.parameter.id;
const ss=SpreadsheetApp.getActive();
sh=sh | | ss.getActiveSheet();
var vs=sh.getRange(1,1,sh.getLastRow(),1).getValues();
var d=0;

对于(var i=0;i,仅支持以下HTTP方法:

  • POST
  • GET
DELETE
方法不受支持

您可以使用post:

服务器端:

函数doPost(e){
如果(e.parameter.option==“DELETE”)返回doDelete(e);
/*剩下的都在这里*/
}
反应:

  // convert to axios.post
  deleteInfo = (e) => {
    console.log(e);
   axios.post(api,{//modified
     id: e,
     option: "DELETE",//added
   },optionAxios)
   .then((res) =>{
     this.getInfo(res);
     console.log('success!');
   })
    
  }

很抱歉回复..我已解决此错误!!同时,我将尝试删除从现在开始选择的行。谢谢~!感谢您的回复。我将参考您的代码!祝您编码愉快!
  // convert to axios.post
  deleteInfo = (e) => {
    console.log(e);
   axios.post(api,{//modified
     id: e,
     option: "DELETE",//added
   },optionAxios)
   .then((res) =>{
     this.getInfo(res);
     console.log('success!');
   })
    
  }