Created
May 20, 2020 06:30
-
-
Save keremtiryaki/ba2f9a55f147f6f3a3f7e5417bddc734 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// don't wait for a response | |
const https = require('https'); | |
let requestAndForget = async (host, path, message) => { | |
message = JSON.stringify(message); | |
var options = { | |
hostname: host, | |
method: 'POST', | |
path: path, | |
headers: { | |
'Content-Type': 'application/json', | |
'Content-Length': Buffer.byteLength(message), | |
}, | |
}; | |
await new Promise((resolve, reject) => { | |
let req = https.request(options); | |
req.on('error', (e) => { | |
console.error(`problem with request: ${e.message}`); | |
reject(e); | |
}); | |
req.write(message); | |
req.end(() => { | |
console.log("NOW it's not λ1's problem anymore."); | |
resolve(); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment