Last active
September 1, 2021 11:49
-
-
Save persianturtle/8ea183176c765a5e2a2fd558cb9b7e7a 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
const https = require('https') | |
const options = { | |
hostname: 'example.com', | |
port: 443, | |
method: 'PUT', | |
headers: { | |
'Content-Type': '<whatever>', | |
Authorization: | |
'Bearer <token>', | |
}, | |
path: "/uri/path/here" | |
} | |
const response = await new Promise((resolve, reject) => { | |
const request = https.request( | |
options, | |
(response) => { | |
response.setEncoding('utf8') | |
let body = '' | |
response.on('data', (chunk) => { | |
body += chunk | |
}) | |
response.on('end', () => { | |
// if the response is JSON | |
body = JSON.parse(body) | |
console.log(body) | |
}) | |
} | |
) | |
request.on('error', reject) | |
request.end() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment