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

243
Views
Is there a better way to setup google API script without getting an error?

I am trying to set up Google API on a project I am working on and it seems to be throwing an error upon running the app. Below are steps to reproduce the error:

  1. Copied and pasted script tag provided by Google.

     <script async defer src="https://apis.google.com/js/api.js"
      onload="this.onload=function(){};loadClient()"
      onreadystatechange="if (this.readyState === 'complete') this.onload()">
     </script>
    
    
  2. Pasted the script in my _app.js file as shown below

     import "./styles.css";
     import Script from "next/script";
     import { SessionProvider } from "next-auth/react";
     import Layout from "../components/layout";

export default function App({ Component, pageProps: { session, ...pageProps } }) {
  return (
    <SessionProvider session={session} refetchInterval={5 * 60}>
      <Layout>
        <Component {...pageProps} />
        <Script
          async
          defer
          src="https://apis.google.com/js/api.js"
          onload="this.onload=function(){};loadClient()"
          onreadystatechange="if (this.readyState === 'complete') this.onload()"
        />
      </Layout>
    </SessionProvider>
  );
}

  1. Ran the code and got ReferenceError: loadClient is not defined

I didn't think I would have to "define" loadClient as it is part of the provided Google script. All pointers to resolving this issue are very much appreciated.

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!