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

154
Views
Not getting back any data using axios and tv maze api

I'm trying to get search data using the axios plugin from the TV Maze Api

    <form method="POST" action="/results">
  <input type="text" name="searchTerm" placeholder="Search for shows">

  <input type="submit" value="Search">

</form>

I'm using a handlebar to post the information to my app.js

//Sets up results page
app.get("/results", mware.requireLogin, function(req, res) {

  const simplifiedUser = {
    username: req.user._doc.username, 
    isAdmin: req.user._doc.isAdmin
  };

  res.render("results", {
    message: req.flash('info'),
    user: simplifiedUser
  });
});

// Process the form submission
app.post('/results', async function(req, res) {

    const results = await showService.searchShows(req.body.searchTerm);
    if(results && results.shows) {
        res.render('results', {
            results: results.shows,
            searchTerm: req.body.searchTerm
        });
    } else {
        res.render('error');
    }

}); 

It then sends it off to retrieve that data but nothing is coming back. It keeps on skipping the data and goes straight ro rendering out the error message.

const showService = {

searchShows: async (term) => {
  //searches for shows
  //   /search/shows?q=query
  
    try {

      const options = {
      params: {
        term,
      }
  };

      const response = await axios.get(show_api + '/search/shows?q=', options);


    if(response && response.data){
      return response.data;
    } else {
      return ["did not work"];
    }
      //console.log(response);
    } catch (error) {
      console.error(error.response.data);
    }
  }

};

Any solution would help a lot thank you

about 4 years ago · Juan Pablo Isaza
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!