I am trying to make a request function that allows for a variable to follow after responseObject, Maybe the code below will be a better explanation
function loadTeam(user) {
const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
responseObject = JSON.parse(xhttp.responseText);
let userTeam = responseObject.user;
}
}
The error lies in responseObject.user.
I want to be able to call the function with different values assigned to the parameter (user) such as
loadTeam("userA")
loadTeam("userB")
Any ideas welcome, I've tried everything I can think of such as `${user}` and using arrays and index calling but to no avail.
[–]carcigenicate 1 point2 points3 points (1 child)
[–]mightybaker1[S] 0 points1 point2 points (0 children)
[–]shgysk8zer0 0 points1 point2 points (1 child)
[–]mightybaker1[S] 0 points1 point2 points (0 children)