Recently, I've been diving into the world of Javascript and delving deep into AJAX. Utilizing Vanilla JS along with simple AJAX, my current task involves fetching a user object from a URL based on the user's input ID. Despite attempting to use .data, I am encountering issues getting it to function properly.
async function display() {
try {
let id = +userID.value;
const url = `https://jsonplaceholder.typicode.com/users/${id}`;
const response = await fetch(url);
const rootObject = await response.json();
const users = rootObject.data;
getUser(users);
} catch (err) {
alert(err.message);
}
}
display()
Within my code lies another function - getUsers(users), which remains empty due to its malfunctioning state. How can I successfully retrieve the desired object solely from the provided URL?