I have one API which has title, body, and user-id, and I want to print User Name with the help of another API. So how can I do it? I have listed both APIs in below.
getUser(id) {
let userData = fetch(`https://jsonplaceholder.typicode.com/users/${id}`)
.then(response => response.json())
.then((responseJson) => {
return responseJson.name
})
.catch(error => console.log(error)) //to catch the errors if any
console.log(userData);
return userData;
};