So, I am having a problem where 5 of my 6 variables are being transferred from one page to the next correctly, and I am honestly flabbergasted as to why the 6th isnt. Initially, this is where that data originally gets saved.
<Panel>
var UUID = require('UUIDModule');
var guid = UUID.getUUID();
var id = JSON.stringify(guid);
Context.createVehicle(id, vyear.value, vmake.value, vmodel.value, fuelType.value, comments.value);
Context Page ->
function createVehicle(id, vyear, vmake, vmodel, fuelType, comments) {
console.log(id);
var vehicle = {
id: id,
vyear: vyear,
vmake: vmake,
vmodel: vmodel,
fuelType: fuelType,
comments: comments,
}
var emailLong = FirebaseUser.email;
var emailReady = emailLong.slice(0, -4);
var emailShort = emailReady.split(".").join("");
var url = encodeURI(rootURL + "users/" + emailShort + "/vehicles/" + id + ".json");
fetch(url, {
method: 'PUT',
headers: { "Content-Type": "application/json"},
body: JSON.stringify(vehicle)
}).then(function(response) {
console.log(JSON.stringify(response));
return response.json();
}).catch(function(err) {
console.log("2 Error: " + err);
});
vehicles.add(vehicle);
}
</Panel>
That all works just fine. I pull the data back down later when someone goes to load their app, and it all displays correctly. So on my list, when someone selects a vehicle (that was previously saved from the above function) I run this function to transfer the data.
<Panel>
function goToVehicleInfo(arg) {
var vehicle = arg.data;
console.log(JSON.stringify(vehicle));
router.push("vehicleInfo", vehicle);
}
</Panel>
Which works correctly, and in the console it displays this message:
{"vyear":"2014","vmake":"Mazda","vmodel":"3","fuelType":"","comments":"Red","id":"ceeea9d37e7645669141db9720d60d39"}
And on the following page, I .map it to separate that data and display it all in separate text boxes here.
<Panel>
var vehicle = this.Parameter;
Context.vyear = vehicle.map(function(x) { return x.vyear; });
Context.vmake = vehicle.map(function(x) { return x.vmake; });
Context.vmodel = vehicle.map(function(x) { return x.vmodel; });
Context.fuelType = vehicle.map(function(x) { return x.fuelType; });
Context.comments = vehicle.map(function(x) { return x.comments; });
Context.id = vehicle.map(function(x) { return x.id; });
Context page ->
var id = "";
var vyear = "";
var vmake = "";
var vmodel = "";
var fuelType = "";
var comments = "";
</Panel>
Every single one works, except for the line for the id. Which is problematic because I need that id in order to update that vehicles info in the database. Anyone know why?
Thanks in advance!