Giter Club home page Giter Club logo

Comments (11)

alexander-fenster avatar alexander-fenster commented on May 23, 2024

I checked the basic usage of webpacked libraries before we released v37.0.0 and it worked, but let me double check - until we're covered by some real tests, it's very possible we could break something without even noticing. Tests for browser stuff is WIP.

We are not planning to use any polyfills for url module, window.URL works just great for our purposes. It seems that gaxios has no idea (yet) that it should use window.URL, not the url module. If my understanding is correct here I'll try to fix it now.

from gaxios.

alexander-fenster avatar alexander-fenster commented on May 23, 2024

Thanks @dmytrobanasko - I was able to repro that, #45 should fix the problem.

from gaxios.

dmytrobanasko avatar dmytrobanasko commented on May 23, 2024

That was fast =] Thank you!

from gaxios.

JustinBeckwith avatar JustinBeckwith commented on May 23, 2024

🎉 This issue has been resolved in version 1.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from gaxios.

vc102375 avatar vc102375 commented on May 23, 2024

I am still facing this issue on lambda when i run google translate api's...

2019-03-05T18:32:45.289Z 5b2767e6-8af1-47b1-9b50-86ef389b2b78 TypeError: URL is not a constructor
at Gaxios.validateOpts (/var/task/node_modules/gaxios/build/src/gaxios.js:125:27)
at Gaxios. (/var/task/node_modules/gaxios/build/src/gaxios.js:60:25)
at next (native)
at /var/task/node_modules/gaxios/build/src/gaxios.js:19:71
at __awaiter (/var/task/node_modules/gaxios/build/src/gaxios.js:15:12)
at Gaxios.request (/var/task/node_modules/gaxios/build/src/gaxios.js:59:16)
at Object. (/var/task/node_modules/gaxios/build/src/index.js:38:33)
at next (native)
at /var/task/node_modules/gaxios/build/src/index.js:19:71
at __awaiter (/var/task/node_modules/gaxios/build/src/index.js:15:12)

from gaxios.

alexander-fenster avatar alexander-fenster commented on May 23, 2024

@vc102375 How exactly are you using the code? Is it a regular Node.js application - if so, which Node.js version is used?

from gaxios.

alexander-fenster avatar alexander-fenster commented on May 23, 2024

@vc102375 A wild guess: is there any chance that you have a global variable named window defined somewhere? What does 'console.log(typeof window);` print in your code?

from gaxios.

vc102375 avatar vc102375 commented on May 23, 2024

using Node 6.10 , i am calling google translate api's thats all I am doing not calling gaxios directly . all was fine until 14 hours ago when redeployed the api on lambda to fix a issue.

yield translate.translate(text, options)
.then(results => {
console.log(results)
const translation = results[0];
return translation;
})
.catch(err => {
console.error('ERROR:', err);
return false
});

from gaxios.

stephenplusplus avatar stephenplusplus commented on May 23, 2024

This is tracking this issue: #54

from gaxios.

alexander-fenster avatar alexander-fenster commented on May 23, 2024

@vc102375 Oh, that's bad. URL class was added in v6.13.0. The easiest way for you is switching to Node.js v8 since v6 will be EOL in less than a month.

As a quick workaround, you can add this to the very beginning of the your application:

const url = require('url'); // legacy Node6 url
const semver = require('semver');
class Node6CompatibilityURL {
  constructor(str) {
    this.url = url.parse(str);
    this.origin = this.url.protocol + '//';
    this.pathname = this.url.pathname ? this.url.pathname : '';
    this.search = this.url.search ? this.url.search : '';
    this.href = this.url.href ? this.url.href : '';
  }
}

if (semver.lt(process.version, '6.13.0')) {
  window = {};
  window.URL = Node6CompatibilityURL; // no warranty 😱 
}

Make sure you npm install semver to make it work. This code creates a global window object with window.URL that will make gaxios think it's running in browser mode, so it will use this instead of the URL class that will appear in v6.13.0. Thanks for semver check, it will keep working even after you upgrade Node.js. Please try that and let me know if it helped.

from gaxios.

lock avatar lock commented on May 23, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from gaxios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.