skip to Main Content
      const searchMovies=async(title)=>{
        const response =await fetch(`${API_URL}&s=${title}`)
        const data = await response.json();
        setMovies(data.Search)
       }

what is &s inside the api call? what does it do?

tried googling for answers but couldnt find any

2

Answers


  1. The & sign is a separator for query parameters in an URL.
    In your sample s is a query parameter. But maybe the API_URL already contains other query parameters, because before the first parameter usually has to be a ? sign like in this URL of a google search: https://www.google.com/search?client=firefox-b-d&q=test where client is the first parameter (with the value firefox-b-d) and q is the second (with the value test).

    Login or Signup to reply.
  2. It’s part of a query-string which is a component of a universal resource locator (URL), and it is used to separate multiple queries. See parameters.

    If you want to work with query strings in JS, try the URLSearchParams interface, which is part of the web API

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search