Http post usage


I tried feth and http. I can not POST. The PHP print_r () function does not print.
The example in the document does not work either.

        exports.pageLoaded = function() {

        var http = require("http");

            var result;

                url: "",
                method: "POST",
                headers: { "Content-Type": "application/json" },
                content: JSON.stringify({ MyVariableOne: "ValueOne", MyVariableTwo: "ValueTwo" })
            }).then(function (response) {
                 result = response.content.toJSON();
            }, function (e) {
                  console.log("Error occurred " + e);


Could you tell me how my PHP code should be and why not?

Here, “Improve this document” and “Demo Source” links do not work. My God!


  var url  = '';
   var data = "x=" + "aaa";
   fetch(url, { method: 'POST', body: data })
   .then(function (response) {
   return response.json();
   .then(function (body) {   
   console.log(body.veri  )


 $array["veri"] = $_POST['x'];
 echo json_encode($array);


Tks… for some reason the content returned in the JSON.stringify({}) at body, is diferent from the expected format.

I’ve tried your idea and it works!