In the code below, I get an error when I try to setCountryToSearch() saying Argument of type 'void' is not assignable to parameter of type 'Country | ((currVal: Country) => Country)'.
I understand I get the error because searchCountry does not return anything. So how can I fix this? What changes can I make to the interface? I tried putting a return and I still had the same error.
Interface
export interface SearchCountryProp {
  searchCountry: (country: string) => void;
}
Function
 const [countryToSearch, setCountryToSearch] = useRecoilState(countryState);
 const searchCountry = (country: string) => {
    Rest.getCountry(country).then((returnedCountry) => {
      setCountryToSearch(returnedCountry);
    });
  };
Rest
import Axios from "axios";
const Rest = {
  async getCountry(nation: string) {
    Axios.get(`https://restcountries.com/v3.1/name/${nation}`).then(
      (response) => {
        const countryObject = {
          captial: response.data[0].capital,
          continent: response.data[0].continents,
        };
        console.log(countryObject);
        return countryObject;
      }
    );
  },
};
export default Rest;
 
    