Axios not working in Freshservice serverless APP

I am trying to use axios method in my serverless app for API call to third party system. But its giving me error when I am adding it server.js
const axios = require(“axios”);

var token = await
this.url + “auth/oauth/token”,
headers: {
Authorization: "Basic " + Buffer.from(“public-client:public”, “utf8”).toString(“base64”)

Manifest.json file
“dependencies”: {
“axios”: “1.2.1”,
“safe-buffer” : “5.2.1”,

Error [Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ]

I have tried to call API using $ method. But don’t know the syntax, how to add grant type parameter to it. Any one please suggest.

Hi @akash.pagare

Good Day!

Can you please downgrade the Axios version to the last version that was built using common JS? Currently, I am using Axios version 0.27.2 and it’s working.

Hope it helps


1 Like

Hi @Sujith_Guna

Thanks for your valuable feedback. After downgrading the version its working now.
Currently, I am trying to get token from third party system and its returning me below error, whereas the same code in working in plain node js project locally.


Here is code snippet

Hi @Sujith_Guna

I have fixed the API Token issue after changing the URL structure. Thank you for your help and support.

1 Like

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.