# POST Method posting extra items

**URL:** <https://forums.fusetools.com/t/post-method-posting-extra-items/4795>\
**Category:** How-to Discussions\
**Created:** [January 11, 2018, 9:58pm UTC](https://forums.fusetools.com/t/post-method-posting-extra-items/4795 "2018-01-11T21:58:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Mwangi](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@Brian\_Mwangi](https://forums.fusetools.com/u/Brian_Mwangi)\
**Post date:** [January 11, 2018, 9:58pm UTC](https://forums.fusetools.com/t/post-method-posting-extra-items/4795/1 "2018-01-11T21:58:23Z")

</div>

Hi there, I have some TextInputs that capture data and using fetch, send them to my server for storage - as POST JSON.

Here is the JavaScript method to send the data :

```auto
function sendBreakdownRequest() {
			requestObject = {
				names : userfullnames,
				phonenumber : userphonenumber,
				carnumberplate : carnumberplate,
				carmodel : carmodel,
				problem : carproblemdetails,
				latitude : latitude,
				longitude : longitude
			};

			fetch('http:// **** /breakdowntest.php', {
			    method: 'POST',
			    headers: { "Content-type": "application/json"},
			    body: JSON.stringify(requestObject)
			}).then(function(response) {
			    status = response.status; // Get the HTTP status code
			    response_ok = response.ok; // Is response.status in the 200-range?
			    return response.json(); // This returns a promise
			}).then(function(responseObject) {
			    // Do something with the result
			}).catch(function(err) {
			    // An error occurred somewhere in the Promise chain
			});
		}

```

However, the JSON on the server end ends up with extra data i.e

```auto
{
	"names": {
		"_origin": -489,
		"_subscribers": [
			{
				"version": 2,
				"active": true
			}
		],
		"_isProxy": false,
		"_values": [
			"JERMAINE COLE"
		],
		"_beganSubscriptions": true
	}
}

```

What could be the problem ? All I want is the data under ‘\_values’ and not the rest.

Also, what’s the best way to decode the JSON using PHP on the server side ?  
I have been trying the code below and it has not been successful yet :

```auto
<?php
	# Get JSON as a string
	$json_str = file_get_contents('php://input');

	# Get as an object
	$json_obj = json_decode($json_str);

        ....

```

Someone please help out. I would really appreciate it guys!  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [January 12, 2018, 9:04am UTC](https://forums.fusetools.com/t/post-method-posting-extra-items/4795/2 "2018-01-12T09:04:16Z")

</div>

The fact that you’re receiving those additional properties means that you’re serialising and sending over an Observable. The snippet you posted does not explain how you end up doing that, so please show more of your _actual_ code.

As for the PHP side, `json_decode` is pretty much all you need. Make sure you get the right string in input and you’re all set.

---

<div class="post-metadata">

**Author:** ![Brian\_Mwangi](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@Brian\_Mwangi](https://forums.fusetools.com/u/Brian_Mwangi)\
**Post date:** [January 13, 2018, 4:50pm UTC](https://forums.fusetools.com/t/post-method-posting-extra-items/4795/3 "2018-01-13T16:50:32Z")

</div>

Hi there, thanks for getting back to me.

I don’t exactly know where the serialising is happening so I’d be grateful if you go through my code and help me find the needle in the haystack.

Link : [https://pastebin.com/QB8n0LME](https://pastebin.com/QB8n0LME)

IDEA : I’m building a simple breakdown app that gets your location and some few other details, which are then sent to the server, so that a breakdown service can be sent to your location. It’s for a school project.

Thanks in advance sir.

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [January 15, 2018, 10:44am UTC](https://forums.fusetools.com/t/post-method-posting-extra-items/4795/4 "2018-01-15T10:44:08Z")

</div>

There’s not much to look for really, it’s right there:

```auto
        var userfullnames = Observable();
        // ...
            requestObject = {
                names : userfullnames,
                // ...
            };

```

If all of your observables up there are single-value observables, you can just change your `requestObject` to this:

```auto
var requestObject = {
    names : userfullnames.value,
    phonenumber : userphonenumber.value,
    carnumberplate : carnumberplate.value,
    carmodel : carmodel.value,
    problem : carproblemdetails.value,
    latitude : latitude.value,
    longitude : longitud.valuee
};

```

It seems to me that you should spend some time reading [about Observables](https://www.fusetools.com/docs/fusejs/observable) to get a better understanding on how they work.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Brian\_Mwangi](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@Brian\_Mwangi](https://forums.fusetools.com/u/Brian_Mwangi)\
**Post date:** [January 15, 2018, 3:43pm UTC](https://forums.fusetools.com/t/post-method-posting-extra-items/4795/5 "2018-01-15T15:43:46Z")

</div>

Thanks so much for the input. I highly appreciate it.

I will do the corrections to the code and get back to you on the progress.

Thanks, again.

---

<div class="post-metadata">

**Author:** ![Brian\_Mwangi](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@Brian\_Mwangi](https://forums.fusetools.com/u/Brian_Mwangi)\
**Post date:** [January 15, 2018, 4:29pm UTC](https://forums.fusetools.com/t/post-method-posting-extra-items/4795/6 "2018-01-15T16:29:32Z")

</div>

Hi there,  
Thanks alot for your input. Now the data is being sent as I wanted it to.

However, my GeoLocation isn’t working or something is messing up. I’m using the continuous method to change the `longitude` and `latitude` values. On the device, with the `ShowMyLocation="True" ShowMyLocationButton="true"` attributes, the MapView shows the current location. However, the variables are not updated. Hence, when the data is sent, the values appear as 0 and 0.

What might be the cause ?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [January 16, 2018, 10:51am UTC](https://forums.fusetools.com/t/post-method-posting-extra-items/4795/7 "2018-01-16T10:51:06Z")

</div>

That’s not a question related to the one handled in this thread. Please make a new forum post and include a complete, minimal reproduction along with other useful details, such as the target device you’re testing on.
