Parsing HTTP request with Photon


How do we parse HTTP request that I send from node.js client to Photon TCP server (or the node.js server and Photon as client)?

I want to be able to turn on an LED by sending POST request from node.js to Photon.

On the node.js side:

var request = require('request');
// Configure request
var options = {
	url: '',//Photon's IP address
    method: 'POST',
	headers: {
        'Val': value
// Start the request
request(options, function (error, response, body) 
		var json = JSON.stringify({level: body});
		return console.log('Server responded with:',body);
		return console.error('ERROR:', error);

How do we do “if receive POST, do x” with Photon? I tried with the TCPserver and TCPclient library but it didn’t work


You could use HTTPClient or WebServer available as contributed library - or look at their implementation to see how it’s done.