'API_URL' is assigned a value but never used

Viewed 18

What is causing the error?

API_URL and title doesn't work PS shows "Unexpected template string expression"

const API_URL ='http://www.omdbapi.com?apikey=ed015dd';
const App = () => {
const searchMovies = async (title) => {
    const response = await fetch('${ API_URL} & s=${title}')
    const data = await response.json();
    console.log(data.search)
  }
useEffect(() => {
    searchMovies('spiderman')
  }, []);
1 Answers

I think you want to use JS template literals. You have to use the backticks (`) instead of single quotes (').

const response = await fetch(`${API_URL}&s=${title}`);
Related