Created
May 26, 2019 02:21
-
-
Save KameronKales/353d583a223215a6af2d655a3fc54565 to your computer and use it in GitHub Desktop.
Post request sent from JS widget
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 { json, send } = require("micro"); | |
const cors = require("cors"); | |
module.exports = async (req, res) => { | |
res.header("Access-Control-Allow-Origin", "*"); | |
res.header( | |
"Access-Control-Allow-Headers", | |
"Origin, X-Requested-With, Content-Type, Accept" | |
); | |
const body = await json(req); | |
console.log(cors); | |
send(res, 200, body); | |
}; |
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
function save(data, aCallback) { | |
var cookie = data.cookies; | |
var user_settings = data.user_settings; | |
var page_view = data.page_view; | |
var user_data = { user_settings: user_settings, page_view: page_view, cookie: cookie }; | |
console.log( \\`This is our user_data object from the logger function sending to our stream API\\`, user_data ); | |
var api = API + "/email"; | |
console.log(\\`This is our api\\`, api); | |
axios .post(api, user_data) | |
.then(response => { console.log(response); }) | |
.catch(err => { console.log(err); }); | |
aCallback(data); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment