Giter Club home page Giter Club logo

Comments (15)

bryanmacfarlane avatar bryanmacfarlane commented on August 16, 2024 1

Please create an issue tagged with enhancement to suggest making it work from a web page. For now, I will update the docs / readme to make it clearer that it's only supported within node app.

Would be nice though so I'll look into it :)

from typed-rest-client.

bryanmacfarlane avatar bryanmacfarlane commented on August 16, 2024 1

@baxevanis - we eliminated the globals usage in the most recent version - 1.0.2 (npm install typed-rest-client@preview).

Does that version work for you?

from typed-rest-client.

peterblazejewicz avatar peterblazejewicz commented on August 16, 2024

http.globalAgent is undefined

What's your local Node JS version?

from typed-rest-client.

bryanmacfarlane avatar bryanmacfarlane commented on August 16, 2024

I will take a look at this.

from typed-rest-client.

baxevanis avatar baxevanis commented on August 16, 2024

Oh sorry thought I had add that :/
node -v > 8.9.1

And here are the dependencies I have (some might not be required as I was trying to resolve the issue and was not sure if I was missing anything!

  "dependencies": {
    "@types/jquery": "^3.2.16",
    "@types/node": "^8.0.53",
    "node": "^9.2.0",
    "ts-loader": "^3.1.1",
    "typed-rest-client": "^0.12.0",
    "typescript": "^2.6.1",
    "webpack": "^3.8.1"
  }

from typed-rest-client.

bryanmacfarlane avatar bryanmacfarlane commented on August 16, 2024

hmmm. I can't repro and global agent has been there forever

https://nodejs.org/api/http.html#http_http_globalagent

I'll try your sample. Did you create a server @ https://sample-api.dev/ping that returns a resource?

from typed-rest-client.

bryanmacfarlane avatar bryanmacfarlane commented on August 16, 2024

Also, I see you're trying to use this library in a web page? Right now, it's only supported to use within a node app. Perhaps that's why?

from typed-rest-client.

baxevanis avatar baxevanis commented on August 16, 2024

Yes this is a demo api server that returns a json response.
And yes I am trying to use the lib on a web page!

OK this is why then!

Thank you for clarifying and looking into this

from typed-rest-client.

bryanmacfarlane avatar bryanmacfarlane commented on August 16, 2024

morphed this task. Thanks for the feedback.

from typed-rest-client.

experimenti avatar experimenti commented on August 16, 2024

Thanks for your contributions.
I hit this as well - maybe for the same naïve reason.
I'd like fork and build an http client (typed and in typescript) that can (via rollup) transpile down and be node compatible. Write once, run everywhere. ;)

My efforts floundered on configuring rollup with plugins to pull the node globals along.

from typed-rest-client.

bryanmacfarlane avatar bryanmacfarlane commented on August 16, 2024

@baxevanis or @johndouglascm - we do take contributions. even if you don't complete the contribution, outlining your process / requirements (webpack) etc... would help whoever does the work. Also, if you had partial work completed, referencing those from a fork would help whoever picks up the work.

from typed-rest-client.

sinmaniphel avatar sinmaniphel commented on August 16, 2024

I've had the issue an can provide an explanation as to why the globalAgent property of the http module is not present in the browser.
This is not directly linked to the nodeJs version.

When using Webpack or Browserify, some core node modules are not natively included, and are replaced by those in
https://github.com/webpack/node-libs-browser

to wit, the http module is actually
https://github.com/jhiesey/stream-http

I suppose the browser being a default agent in itself with properties set by user preferences, such a property would be redundant, or something like that.

I strongly support this enhancement. Totally eliminating the globals may not be mandatory, if you had a good reason to set them in a non browser environment. A check should be sufficient.

As is, commenting the line works well for me for now.
Awaiting the preview version to become stable.

Thanks for the good work ;)

from typed-rest-client.

baxevanis avatar baxevanis commented on August 16, 2024

Sorry for the late response.
I finally found some time to test the new version and it works like a charm!!!
I've replaced the previous library I was using and from 2.21mb now the final file went down to 408k!!

Thank you!!

from typed-rest-client.

bryanmacfarlane avatar bryanmacfarlane commented on August 16, 2024

@baxevanis - Awesome! we're just waiting on ntlm issue then we will release. The preview outside of that is solid.

If you ever have time to do a PR on a markdown file for using it in a web page, that would be awesome. But I'll get to it if you don't :)

Thanks

from typed-rest-client.

bryanmacfarlane avatar bryanmacfarlane commented on August 16, 2024

Closing since it works now

from typed-rest-client.

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.