I am using this API: “https://rickandmortyapi.com/api/character/?page=2&name=rick”
With javascript I have to get the values of the characters of Rick & Morty with fetch:
The response.json() when I look for the character ”Rick” returns this:
But in the return, I want only to get the first character in the array (In the image the yellow square)
const fetch = require ('node-fetch');
function searchCharacter(){
fetch(`https://rickandmortyapi.com/api/character/?name=rick`)
.then( (response) => {
let array = response.json();
return array;
})
.then ( (body) => {
console.log(body);
})
}
searchCharacter();