Socket
Socket
Sign inDemoInstall

node-angular-http-client

Package Overview
Dependencies
6
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

2

package.json
{
"name": "node-angular-http-client",
"version": "1.0.4",
"version": "1.0.5",
"description": "The Angular 4.3 HttpClient for node.js",

@@ -5,0 +5,0 @@ "keywords": [

@@ -10,5 +10,57 @@ # Angular4's HttpClient for node.js

will create and resolve the `HttpClient` for you, giving you an
instance of it to use directly.
instance of it to use directly. It takes an _options_ object within
which the `interceptors` key is an array of `HttpInterceptor`s.
**Note**:`HttpClient` taken from `Angular 5.0.0-beta.5`,
**Note**: `HttpClient` taken from `Angular 5.0.0-beta.5`,
and made to work independently of Angular.
### Examples
#### 1. `injection-js`
```typescript
@Injectable()
class TestInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
console.warn('intercepted');
return next.handle(request);
}
}
@Injectable()
class GoogleTest {
constructor(private httpClient: HttpClient) {}
run() {
this.httpClient.get('http://www.google.com', {responseType: 'text'}).subscribe(
res => console.dir(res)
);
}
}
const injector = ReflectiveInjector.resolveAndCreate([
...HTTP_CLIENT_PROVIDERS,
{ provide: HTTP_INTERCEPTORS, useClass: TestInterceptor, multi: true },
GoogleTest
]);
const googleTest = injector.get(GoogleTest);
googleTest.run();
```
#### 2. Non-IoC usage
```typescript
class TestInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
console.warn('intercepted');
return next.handle(request);
}
}
const httpClient: HttpClient = createHttpClient({interceptors: [TestInterceptor]});
httpClient.get('http://www.google.com', {responseType: 'text'}).subscribe(
res => console.dir(res)
);
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc