URL('http://html5.ohtsu.org/'); function promisifiedGet(url) { return new Promise((resolve, reject) => { http.get(url, (res) => { res.statusCode === 200 ? resolve(res) : reject(new Error('No response data')); }); }); } promisifiedGet(url).then((res) => { let data = ''; res.setEncoding('utf-8'); res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { console.log('Response: ', data); }); }).catch((e) => { console.log('Error: ', e.message); }).finally(() => { console.log('final called'); }); BTZODGVODUJPOͰUSZʙDBUDIʙpOBMMZ͕͑Δ͔Βͦͬͪͷํ͕ྑ͘ͳ͍ʁ