Comments (15)
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.
@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.
http.globalAgent is undefined
What's your local Node JS version?
from typed-rest-client.
I will take a look at this.
from typed-rest-client.
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.
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.
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.
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.
morphed this task. Thanks for the feedback.
from typed-rest-client.
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.
@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.
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.
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.
@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.
Closing since it works now
from typed-rest-client.
Related Issues (20)
- Sending body with delete request HOT 3
- Underscore 1.12.1 being used shows vulnerability https://npmjs.com/advisories/1674
- Possible regression in proxy variable processing HOT 4
- SyntaxError: Invalid regular expression: invalid group specifier name HOT 3
- Confusing deprecation: "1.8.5 contains changes that are not compatible with Node 6" HOT 3
- Update Azure pipeline and remove GitHub action HOT 2
- Authentication header is set on redirect request HOT 1
- ETIMEDOUT for certain calls on Node 16 HOT 5
- Performance issues with readBody in HttpClient.ts HOT 3
- error from zlib not handled properly in decompressGzippedContent() HOT 4
- This repo is missing important files
- Unable to read error message from response header HOT 3
- uncaught reference error: the process does not define in browser HOT 11
- not working with react with next js , HOT 3
- Discussion: use with fetch API HOT 5
- Incorrect header check error while decompressing a response HOT 2
- Chrome 113 breaks typed-rest-client HOT 3
- Please tag released versions HOT 4
- Add `EHOSTUNREACH` to `NetworkRetryErrors` list HOT 1
- Add support to REST client for getting binary data HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typed-rest-client.