hey guys i dont know why my setPlaceId works but not my setPlaceName doesnt print anything when there is some data that should be printed out could someone help? (i have both placeId and placeName in a p tag)
import React, { useState, useEffect } from "react";
import SearchPlaces from "./SearchPlaces";
function ConvertPlaces() {
const [userInput, setUserInput] = useState("");
const [inputField, setInputField] = useState("");
const [savedInput, setSavedInput] = useState("");
const [placeName, setPlaceName] = useState("");
const [placeId, setPlaceId] = useState("");
useEffect(() => {
convert();
}, []);
const convert = () => {
fetch(
`https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/autosuggest/v1.0/UK/GBP/en-GB/?query=${userInput}`,
{
method: "GET",
headers: {
//i deleted this cuz of api keys
},
}
)
.then((res) => res.json())
.then((response) => {
console.log(response);
setPlaceName(response.Places.map((airport) => airport.PlaceName));
setPlaceId(response.Places.map((airport) => airport.PlaceId));
})
.catch((err) => {
console.log(err);
});
};
const handleChange = (event) => {
setInputField(event.target.value);
setUserInput(event.target.value);
};
const handleSubmit = (event) => {
event.preventDefault();
setSavedInput(inputField);
setInputField("");
convert();
};
return (
<div>
<SearchPlaces
run={convert}
handleChange={handleChange}
handleSubmit={handleSubmit}
inputField={inputField}
userInput={userInput}
savedInput={savedInput}
/>
<p>sfdajfp</p>
<p>{placeId}</p>
<p>{placeName}</p>
</div>
);
}
export default ConvertPlaces;