Friday 25 January 2019

Error: Can't set headers after they are sent.

im trying to create a POST route to my Device management/Device Configurations end point​I've tried different methods, also followed the documentation on microsoft.com Used the graph explorer, which handles everything for you.​// in my graph.js file, this is the functions that is being used to post to the endpoint.​postIntuneForm: async function(accessToken) {const client = getAuthenticatedClient(accessToken);const intuneForm = await client.api('/deviceManagement/deviceConfigurations').version('beta').post({}, (err, res) => {console.log("=================");});return intuneForm;} };​// file: /routes/intune.js​router.post('/',async function(req, res) {if (!req.isAuthenticated()) {// Redirect unauthenticated requests to home pageres.redirect('/')} else {let params = {active: { Intune: true }};​// Get the access tokenvar accessToken;try {accessToken = await tokens.getAccessToken(req);} catch (err) {res.json(err);}​if (accessToken && accessToken.length > 0) {try {// Get the eventsvar postToIntune = await graph.postIntuneForm(accessToken);​res.json(events.value);} catch (err) {res.json(err);}}}});​module.exports = router;I expected the form results to be posted into the end point as json.​I am getting an error: "Can't set headers after they are sent."

Submitted January 25, 2019 at 07:11PM by JRTHEGR8

No comments:

Post a Comment