const https = require('https'); exports.handler = async (event, context) => { return new Promise((resolve, reject) => { const options = { hostname: 'api.travis-ci.org', path: `/repo/${process.env.TRAVIS_CLIENT_NAME}%2F${process.env.TRAVIS_REPO_NAME}/requests`, method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Travis-API-Version': 3, 'Authorization': `token ${process.env.TRAVIS_API_KEY}` } }; const post_data = JSON.stringify({ request: { branch: "master" } }); const req = https.request(options, (res) => { resolve('Success'); }); req.on('error', (e) => { reject(e.message); }); // send the request req.write(post_data); req.end(); }); };