require returning Object instead of Function

Hi,

I’m trying to use google data api npm. Using a require like this:

var urlshortener = google.urlshortener('v1');

Which should return this:

function Urlshortener(options) {
}
module.exports = Urlshortener;

but instead of Fuse.Scripting.V8.Function it returns a Fuse.Scripting.V8.Object.

Hey Bjørn-Olav,

That sounds like a potential bug. Can you provide everything we need to reproduce the problem?

Cheers!

Hey again!

As far as I can tell, the requireAPI function in your code has already invoked the function, which is why you’re getting an object. I’ve added some comments to the relevant part of your code to explain what I mean:

      var endpointPath = 'fusejs_lib/googleapis_apis_urlshortener_v1.js';
      var Endpoint = require(endpointPath); // <-- this returns a function, namely the Urlshortener constructor
      var ep = new Endpoint(options);  // <-- this invokes the constructor and returns an object
      ep.google = this; // for drive.google.transporter
      return Object.freeze(ep); // create new & freeze

Hope that helps! :slight_smile: