Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Axios POST在添加错误捕获后引发错误:ReferenceError:未定义axiosRequest_Javascript_Vue.js_Error Handling_Axios - Fatal编程技术网

Javascript Axios POST在添加错误捕获后引发错误:ReferenceError:未定义axiosRequest

Javascript Axios POST在添加错误捕获后引发错误:ReferenceError:未定义axiosRequest,javascript,vue.js,error-handling,axios,Javascript,Vue.js,Error Handling,Axios,我在axios请求的catch函数中添加了一个错误日志记录。自从我这么做了,我就明白了: 注意:axios post请求未成功。这不是由于服务器的原因,因为从sendByte()直接调用axios.post时,它可以工作 编辑:重新生成代码后,错误消失。该错误以某种方式从再次删除的上一次提交中持续存在。因为我想理解错误,所以我提供了下面的代码 以下是执行axios请求的函数: axiosRequest(payload, path, request) { if (request ===

我在axios请求的catch函数中添加了一个错误日志记录。自从我这么做了,我就明白了:

注意:axios post请求未成功。这不是由于服务器的原因,因为从sendByte()直接调用axios.post时,它可以工作

编辑:重新生成代码后,错误消失。该错误以某种方式从再次删除的上一次提交中持续存在。因为我想理解错误,所以我提供了下面的代码

以下是执行axios请求的函数:

axiosRequest(payload, path, request) {
      if (request === "POST") {
        axios
          .post(path, payload)
          .then(response => {
            console.debug(
              `${path}? \n Status-Code ${response.status} - ${response.data.status} [${pin}]@${port}`
            );
            this.response = response.data;
          })
          .catch(error => {
            // Error The first problem was caused due to running code not being up-to-date with what I saw in the editor. Shouldn't trust hot-plug too much on my part.

After going back in the file history to the point where the axiosRequest function was still there, I've rebuilt and found the error in my code.

It was rather simple:

.then(response => {
            console.debug( // here is the Reference Error -> Fix: [${payload.pin}]@${payload.port}
              `${path}? \n Status-Code ${response.status} - ${response.data.status} [${pin}]@${port}`
            );
            this.response = response.data;
          })
axiosRequest(有效负载、路径、请求){
如果(请求==“发布”){
axios
.post(路径、有效载荷)
。然后(响应=>{
console.debug(
`${path}?\n状态代码${response.Status}-${response.data.Status}[${pin}]@${port}`
);
this.response=response.data;
})
.catch(错误=>{

//错误第一个问题是由于运行的代码不是我在编辑器中看到的最新版本。我不应该太相信热插拔

在文件历史记录中回到axiosRequest函数仍然存在的位置后,我重新构建并在代码中发现了错误

这相当简单:


哪一行是
可视化.vue
中的第185行?这是方法块的开头:
方法:{
。我现在已经在问题的地方添加了行号。你确定你正在查看的代码是正在运行的代码吗?错误消息表明第185行应该在你的
sendByte
方法中。我也看不到你的代码中的任何地方,这是因为axiosRequest不在那里。但我只是想确认一下当然,我会用我提供的东西重新构建它。好的..这里似乎有什么问题。在重新构建之后,错误消失了…但只是为了澄清一下:axiosRequest确实是一个函数,在之前尝试将所有axios请求放入一个函数中。我应该提供该代码吗?
axiosRequest(payload, path, request) {
      if (request === "POST") {
        axios
          .post(path, payload)
          .then(response => {
            console.debug(
              `${path}? \n Status-Code ${response.status} - ${response.data.status} [${pin}]@${port}`
            );
            this.response = response.data;
          })
          .catch(error => {
            // Error The first problem was caused due to running code not being up-to-date with what I saw in the editor. Shouldn't trust hot-plug too much on my part.

After going back in the file history to the point where the axiosRequest function was still there, I've rebuilt and found the error in my code.

It was rather simple:

.then(response => {
            console.debug( // here is the Reference Error -> Fix: [${payload.pin}]@${payload.port}
              `${path}? \n Status-Code ${response.status} - ${response.data.status} [${pin}]@${port}`
            );
            this.response = response.data;
          })