npm package import issue

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
thomas
User
Posts: 131

npm package import issue

Post by thomas »

This my first time to use npm package and I am beginner here

I am trying to search a name from the truecaller API
for it I have add the npm package "truecallerjs" from the Tools -> npm Package

from the example of truecallerjs documents
I have added the following code under the
Client Script -> Global -> Startup Script

import truecallerjs, { SearchData, Format } from "truecallerjs";

async function performTruecallerSearch(): Promise<void> {
  const searchData: SearchData = {
    number: "9912345678",
    countryCode: "IN",
    installationId: "a1k07--Vgdfyvv_rftf5uuudhuhnkljyvvtfftjuhbuijbhug",
  };

  try {
    const response: Format = await truecallerjs.search(searchData);
    console.log(response.json());

    // Additional response methods:
    // console.log(response.xml());
    // console.log(response.yaml());
    // console.log(response.text());

    // Example of available data from the response:
    console.log(response.getName()); // "Sumith Emmadi"
    console.log(response.getAlternateName()); // "sumith"
    console.log(response.getAddresses()); // {....}
    console.log(response.getEmailId()); // example@domain.com
    console.log(response.getCountryDetails()); // {...}
  } catch (error) {
    console.error("Error occurred:", error);
  }
}

performTruecallerSearch();

When I check on the console I got an error as -
Uncaught SyntaxError: Cannot use import statement outside a module


arbei
User
Posts: 8739

Post by arbei »


Post Reply