Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.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
使用带有基本身份验证的express和node.js执行get操作时出现ETIMEDOUT错误_Node.js_Angular_Express - Fatal编程技术网

使用带有基本身份验证的express和node.js执行get操作时出现ETIMEDOUT错误

使用带有基本身份验证的express和node.js执行get操作时出现ETIMEDOUT错误,node.js,angular,express,Node.js,Angular,Express,我试图从我的项目(angular2服务器端)中的外部url获取一些数据。我总是犯ETIMEDOUT错误。这是我的密码 var request = require('request'); var username = "username", password = "pwd", url = "myURL", auth = "Basic " + new Buffer(username + ":" + password).toString("base

我试图从我的项目(angular2服务器端)中的外部url获取一些数据。我总是犯ETIMEDOUT错误。这是我的密码

 var request = require('request');

 var username = "username",
        password = "pwd",
        url = "myURL",
        auth = "Basic " + new Buffer(username + ":" + password).toString("base64");

    request(
        {
            method: 'GET',
            url: url,
            headers: {
                "Authorization": auth
            }
        },
        function (error, response, body) {
            console.log('Error: '+error);
            console.log('Response: '+response);
            console.log('Body: '+body);
        }
    );