I am trying to get 200 status code in response, but as a result it's ETIMEDOUT. I can't understand, how is it possible that I can grab successful response via postman, but same via node-fetch responding with ETIMEDOUT always. Here is an example of code:
const Resource = {
get: cb => {
fetch('', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: {...some body...},
}).then(res => {
if (res.status !== 200) cb(`Status: ${res.status}, ${res.statusText}`)
return res.text()
}).then(data => {
cb(null, data)
}).catch((err) => {
console.log('ERROR: ', err)
})
}
}
and here is response:
ERROR: { FetchError: request to failed, reason: connect ETIMEDOUT
at ClientRequest.<anonymous> (C:\Users\projects\DSSRQ\node_modules\node-fetch\lib\index.js:1393:11)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _binedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
message: 'request to failed, reason: connect ETIMEDOUT',
type: 'system',
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT' }
I am trying to get 200 status code in response, but as a result it's ETIMEDOUT. I can't understand, how is it possible that I can grab successful response via postman, but same via node-fetch responding with ETIMEDOUT always. Here is an example of code:
const Resource = {
get: cb => {
fetch('https://example.', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: {...some body...},
}).then(res => {
if (res.status !== 200) cb(`Status: ${res.status}, ${res.statusText}`)
return res.text()
}).then(data => {
cb(null, data)
}).catch((err) => {
console.log('ERROR: ', err)
})
}
}
and here is response:
ERROR: { FetchError: request to https://example. failed, reason: connect ETIMEDOUT
at ClientRequest.<anonymous> (C:\Users\projects\DSSRQ\node_modules\node-fetch\lib\index.js:1393:11)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _binedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
message: 'request to https://example. failed, reason: connect ETIMEDOUT',
type: 'system',
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT' }
- Are you actually having http or https as protocol? – The Oracle Commented Jul 25, 2018 at 16:49
- this one is covered by https – blindeveloper Commented Jul 25, 2018 at 17:29
- your target host is using what protocol? http or https? – The Oracle Commented Jul 25, 2018 at 17:32
- my target host is using https protocol – blindeveloper Commented Jul 26, 2018 at 8:33
- I am doing in on my local nodejs environment. I've tried using cross-fetch lib (npmjs./package/cross-fetch) with default example of fetching data and got the same error. – blindeveloper Commented Jul 26, 2018 at 9:55
1 Answer
Reset to default 4It looks like it was because of the proxy limitation.