I'm currently facing a Scope issue that has been quite challenging to resolve. The saying goes, "a picture is worth a thousand words," and in this case, it couldn't be more true. Whenever the OK or REJ buttons trigger the reject() function, passing the user_id as id parameter, I encounter an error in Firefox's JS console: "ReferenceError: BUUS123US163 is not defined." Interestingly, while the error does mention the specific id needed, my attempts with shallow and deep copies into a Global array called theUsers have proved ineffective. Could someone please shed light on what seems to be a persistent Scope problem?
Update: JSON.parse error In the .catch clause of the reject() function
// obtaining function: JSON.parse error
function reject(id) {
console.log("hey: rejection is executed... ");
// User Data
const data2 = {
user_id: '',
utility: 'delete'
}
data2.user_id = id;
// // POST : provide user
http.post('http://localhost:9999/Password/empapproval', data2)
.then(data => console.log(data))
.catch(err => console.log(err));
}
// http.post invokes the following:
post(url, data) {
console.log("easyHttp is executing ...");
return new Promise((resolve, reject) => {
console.log("easyHttp Promise is executing ...");
fetch(url, {
method: 'POST',
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify(data)
})
.then(res => res.json())
.then(data => resolve(data))
.catch(err => reject(err));
});
}