As the linked documentation mentions, the http2 module is not supported on Forge. This is because Forge apps do not execute in a true Node.js runtime, but instead execute in a vanilla JavaScript sandbox - some built-in libraries and features of Node are not available in Forge.
Since the googleapis module has a depending on the http2 module, it won’t work when used within a Forge app.
There is an option we can set to disable http2 while using googleapis. Below is the code snippet:
const { google } = require("googleapis");
google.options({
http2: false
});
I tried this and I am able to call API successfully and I am getting proper responses. But the warning still persists.
Should I switch to google-api-javascript-client even if I get the proper API response?
@SagarGujarati - that sounds like it would be fine, as long as you trust that option works as described. The Forge CLI can only detect incompatible libraries by statically analysing your projects dependency tree - if you are confident that the dependency is not actually invoked at runtime, then it’s safe to ignore the warning.