Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
I have a graphql query. How can I manage my 'title' useState with it? I'd like that the title would be in the query instead of "Bad boys" to send

I have a graphql query and a working useState. How can I manage my 'title' useState with it? I'd like that the title would be in the query instead of "Bad boys" to send.

    function Home() {
  const [title, setTitle] = useState("");

  const searchMovies = async (e) => {
    e.preventDefault();
    console.log("submitting");

    const query = `{
    searchMovies(query: "Bad boys") {
    id
    name
    overview
    releaseDate
    cast {
      id
      person {
        name
      }
      role {
        ... on Cast {
          character
        }
      }
    }
  }
}`;


    const url = "https://tmdb.sandbox.zoosh.ie/dev/graphql";

    try {
      request("https://tmdb.sandbox.zoosh.ie/dev/graphql", query).then((data) =>
        console.log(data)
      );
    } catch (err) {
      console.log(err);
    }
  };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The query is an interpolated string so you can pass variables into it like this:

const query = `{
    searchMovies(query: ${title}) {
    id
    name
    overview
    releaseDate
    cast {
      id
      person {
        name
      }
      role {
        ... on Cast {
          character
        }
      }
    }
  }
}`;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!