Skip to content

Instantly share code, notes, and snippets.

@jason-dark
Created July 8, 2018 22:12
Show Gist options
  • Save jason-dark/84f7d09a9fc30207b96cafcbdfe6db76 to your computer and use it in GitHub Desktop.
Save jason-dark/84f7d09a9fc30207b96cafcbdfe6db76 to your computer and use it in GitHub Desktop.
const sfAuth = require('../fetch-data/sf-auth');
const sfQuery = require('../fetch-data/sf-query');
const sendRes = require('../fetch-data/send-res');
exports.handler = function (req, res) {
if (req.method !== "GET") {
console.log("✘ Request was not GET");
sendRes(res, 405, "Not Allowed");
}
else {
sfAuth()
.then(conn => {
sfQuery(conn)
.then(data => { sendRes, 200, data })
.catch(e => { sendRes(res, 500, "Server Error") })
})
.catch(e => { sendRes(res, 500, "Server Error") });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment