Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.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
Post can';t修改";全局变量";在axios中调用_Post_Var_Axios - Fatal编程技术网

Post can';t修改";全局变量";在axios中调用

Post can';t修改";全局变量";在axios中调用,post,var,axios,Post,Var,Axios,我有下一个JSX代码 let answer = true; var postAxios = axios({ method: 'post', url: httpLink, params: {table: tableName}, data: rowInfo } )

我有下一个JSX代码

let answer = true;
var postAxios = axios({
                method: 'post',
                url:     httpLink,
                params: {table: tableName},
                data: rowInfo
               }          
              )
             .then(function (response) {
                 console.log(response);
                 alert(response);
                 answer = true;

               })
              .catch(function (error) {
                  console.log(error);
                  alert(error);
                  answer = false;
               });  
return answer;

answer的最终值上,一些事务需要继续(answer==true)或停止(answer==false)。我的问题是,当执行catch部分时,答案总是真的。有什么办法可以解决这个问题吗?

您的问题是一个“经典”问题的变体,它基于对异步编程工作原理的误解。请参阅可能的副本