回调函数的Javascript范围(React.js)

时间:2016-09-27 12:01:18

标签: javascript reactjs callback fetch

我正在使用Fetch api。 我面临回调变量的范围问题。

我的代码是这样的。

          var check; 

               fetch('http://localhost/react_task/dunckelsecure/php/credentialscheck.php'
        ).then(function (res) {
            return res.text();
        }).then(body => {
            console.log('body is ', body);
            // update
            check = "hey";
        });
         // how to declare value of check globally
        console.log('set body contain value is', body);

如何获得身体外的价值

对此有任何帮助......

更新..如何全局访问检查变量

0 个答案:

没有答案