Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I delegate a httpServer response as an express server post response
    primarykey
    data
    text
    <p>In my scenario, I have frameworks comprising of SAP Business Data(in json format), nodejs middle layer and a Browser front-end. I need to create a real-time application of pull the SAP business to the front-end, make edits and send the edited data back to the sap server.</p> <p>Now, to achieve this I am using <code>express</code> and <code>http</code> module. I am using express(post request) to connect to sap backend and retrieve data in json format and have embedded a http webserver, which is hosting the json data as an url used by the front-end.</p> <p>When the user, make edits in the front-end, I am able to get the response from the httpServer instance response, but the outer express post response is returning before I can delegate the httpResponse form the browser as the express post response.</p> <p>I am including a part of the code, or illustration :</p> <pre><code> app.post('/publish', auth, function (request, response) { json = JSON.stringify(request.body); //io.sockets.emit("SAP_Event", request.body); http.createServer(function(req,res){ //var f = 'index.html'; if(res.url == '/favicon.ico'){ // To handle non-existant favicon request by the http client res.writeHead(404,{'Content-Type' : 'text/plain'}); res.end('Couldn\'t locate the required resource'); return; } var headers = { 'Content-type' : 'application/json' , 'Access-Control-Allow-Origin' : '*', 'Access-Control-Allow-Headers' : 'X-Requested-With,GET,Content-Type'}; res.writeHead(200,headers); res.end(json); //*********************************** if(req.method === "POST") { var data = ""; req.on("data", function(chunk) { data += chunk; }); req.on("end", function() { jsonp = qs.parse(data); }); } //*********************************** }).listen(8080); response.send(jsonp); }); </code></pre> <p><strong>Note:</strong> json is the pulled json(sap -> frontend) jsonp is the pushed(modified) json (frontend -> frontend)</p> <p>I want response.send(jsonp) to send the modified json file, but its returning [] i.e its initial value, moreover I am getting the modified json, the next time restart the server program in sap.<br/>Please Help!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload