# I have a problem  in posting data using json 

**URL:** <https://forums.fusetools.com/t/i-have-a-problem-in-posting-data-using-json/5493>\
**Category:** General\
**Created:** [June 26, 2016, 2:58pm UTC](https://forums.fusetools.com/t/i-have-a-problem-in-posting-data-using-json/5493 "2016-06-26T14:58:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibrahem9311](https://avatars.discourse-cdn.com/v4/letter/i/ecccb3/32.png) [@ibrahem9311](https://forums.fusetools.com/u/ibrahem9311)\
**Post date:** [June 26, 2016, 2:58pm UTC](https://forums.fusetools.com/t/i-have-a-problem-in-posting-data-using-json/5493/1 "2016-06-26T14:58:58Z")

</div>

Hi, I need some help to know what’s wrong with this code

```auto
 <JavaScript>
       var Observable=require"FuseJS/Observable"

       var status=0;
       var response_ok=false;

       var username.value=Observable("");
       var password.value=Obserable("");

      function loginPostData() {
        var myVar={
          "users":{
            "username":"username",
            "password":"password"
          }
        };
        fetch('http://osamaarafa96.esy.es/login.php', {
   method: 'POST',
   headers: { "Content-type": "application/json"},
   body: JSON.stringify(myVar)
}).then(function(response) {
   status = response.status; // Get the HTTP status code
   response_ok = response.ok; // Is response.status in the 200-range?
   console.log("Response: " + JSON.stringify(response));
   return response.json(); // This returns a promise
}).then(function(responseObject) {
   // Do something with the result
   console.log('the API said: ' + JSON.stringify(responseObject));
}).catch(function(err) {
   // An error occured parsing Json
   console.log('Error : the API said: ' + JSON.stringify(responseObject));
});
      }

      module.exports = {
             loginPostData:loginPostData
        }
}

```

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [July 8, 2016, 1:35pm UTC](https://forums.fusetools.com/t/i-have-a-problem-in-posting-data-using-json/5493/2 "2016-07-08T13:35:03Z")

</div>

You just have some small typos. This seems to work:

```auto
<App>
    <JavaScript>
       var Observable = require("FuseJS/Observable");

       var status=0;
       var response_ok=false;

       var username=Observable("");
       var password=Observable("");

      function loginPostData() {
        var myVar={
          "users":{
            "username": username.value,
            "password": password.value
          }
        };
        fetch('http://osamaarafa96.esy.es/login.php&#39;, {
           method: 'POST',
           headers: { "Content-type": "application/json"},
           body: JSON.stringify(myVar)
        }).then(function(response) {
           status = response.status; // Get the HTTP status code
           response_ok = response.ok; // Is response.status in the 200-range?
           console.log("Response: " + JSON.stringify(response));
           return response.json(); // This returns a promise
        }).then(function(responseObject) {
           // Do something with the result
           console.log('the API said: ' + JSON.stringify(responseObject));
        }).catch(function(err) {
           // An error occured parsing Json
           console.log('Error : the API said: ' + JSON.stringify(responseObject));
        });
      }

      module.exports = {
        loginPostData: loginPostData,
        username: username,
        password: password
      }

    </JavaScript>
    <StackPanel>
        <TextBox Value="{username}" />
        <TextBox Value="{password}" />
        <Button Text="ok" Clicked="{loginPostData}" />
    </StackPanel>
</App>

```

---

<div class="post-metadata">

**Author:** ![ibrahem9311](https://avatars.discourse-cdn.com/v4/letter/i/ecccb3/32.png) [@ibrahem9311](https://forums.fusetools.com/u/ibrahem9311)\
**Post date:** [July 13, 2016, 1:50pm UTC](https://forums.fusetools.com/t/i-have-a-problem-in-posting-data-using-json/5493/3 "2016-07-13T13:50:29Z")

</div>

Hi Anders,

i fixed the code as mentioned the result:

 ![file](https://s3.us-east-2.amazonaws.com/fuse-legacy-forum-assets/gMPC931EGHyP-legacy-files-xrEu5VXmktdEMPzQ-Dye_6iolO5UkwzcX_j5TKvGT.png)
