How can call two API with condition in react js?

HI All & @DanCouper

Am in the learning phase so please let me know if something feels illogical. I have been trying to use show result in a way that by default a user should see the trending API results and when he starts searching the other API with search query will trigger or get called. I tried to use if-else but there is no result. It shows the blank. I do not know how can I achieve it. Would really appreciate it if you can help me with this.

Please see the code I have tried. I do not know if it is the logical way or not. Thanks a million in advance.

useEffect (()=> {
        const getMovieList  = async () => {
            const TrendingUrl = '' ;
            const allResultsUrl = `${props.searchText}`;
            const response = await fetch (props.searchText === "" ? TrendingUrl : allResultsUrl);
                    try {
                        const responseJson = await response.json();
                        const data = (responseJson.results);
                    } catch (err) {

 }, [props.searchText]);

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.