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

140
Views
NEXTJS google trend API

Having trouble using the npm google trends api in NEXTJS

Not sure if this is the right way to go about it.

I made a new API route.

http://localhost:3000/api/trends

http://localhost:3000/api/trends

import googleTrendsApi from "google-trends-api";

const handler = async (res, req) => {
  const data = await googleTrendsApi
    .interestOverTime({ keyword: ["Women's march", "Trump Inauguration"] })
    .then(function (results) {
      console.log("These results are awesome", results);
    });

  res.status(200).json({ data: data });
};

I get an error saying

TypeError: res.status is not a function
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this. Here I am using TypeScript, if you are using Javascript, please edit code as needed.

import type { NextApiRequest, NextApiResponse } from 'next'
import googleTrendsApi from "google-trends-api";

type Data = {
  name: string
}

export default function handler(
  req: NextApiRequest,
  res: NextApiResponse<Data>
) {
  const data = googleTrendsApi
    .interestOverTime({ keyword: ["Women's march", "Trump Inauguration"] })
    .then(function (results: any) {
      res.status(200).json(results)
    });
}
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!