0
로컬 httpd 모듈에서 실행중인 etcd 인스턴스에 het 요청을 보내려고합니다.오류 : getaddrinfo ENOTFOUND가 localhost, Nodejs에 요청을 생성하는 중임
같은 코드 모양이
'use strict';
const express = require('express');
const app = express();
var http = require('http');
const port = 10111;
var encoded_url = encodeURI('/v2/keys/message -X GET');
var options = {
host: 'http://127.0.0.1:2379',
path: encoded_url
};
var callback = function (response) {
var str = '';
//another chunk of data has been recieved, so append it to `str`
response.on('data', function (chunk) {
str += chunk;
});
//the whole response has been recieved, so we just print it out here
response.on('end', function() {
console.log(str);
});
}
http.request(options, callback).end();
app.listen(port,() => {
console.log("server started on port " + port);
});
하지만 난 결과를 얻을 터미널에서 같은 컬 요청을하면 나는 다음과 같은 오류
Error: getaddrinfo ENOTFOUND http://127.0.0.1:2379 http://127.0.0.1:2379:80
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
을 얻고있다
컬 http://127.0.0.1:2379/v2/keys/message -X GET
무엇인지 파악할 수 없습니다. 문제.