Created
November 14, 2019 22:43
-
-
Save weienwong/83ef5cc50eb206afd338c458e310e330 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
async function publishItem (instanceZUID, modelZUID, itemZUID, version) { | |
const options = { | |
method: 'POST', | |
hostname: `${instanceZUID}.api.zesty.io`, | |
path: `/v1/content/models/${modelZUID}/items/${itemZUID}/publishings`, | |
headers: { | |
'Content-Type': 'application/json', | |
Authorization: `Bearer ${DEV_TOKEN}` | |
} | |
} | |
const req = https.request(options, function (res) { | |
const chunks = [] | |
res.on('data', function (chunk) { | |
chunks.push(chunk) | |
}) | |
res.on('end', function (chunk) { | |
const body = Buffer.concat(chunks) | |
console.log(body.toString()) | |
}) | |
res.on('error', function (error) { | |
console.error(error) | |
}) | |
}) | |
const postData = { | |
version: version, | |
publishAt: 'now', | |
unpublishAt: '2019-12-31' | |
} | |
req.write(JSON.stringify(postData)) | |
req.end() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment