1
1
import { Injectable } from '@angular/core' ;
2
- import { HTTP_PROVIDERS , Http , XHRBackend , XHRConnection , ConnectionBackend , RequestOptions , RequestOptionsArgs , ResponseOptions , ResponseType , Response , Request , BrowserXhr , XSRFStrategy } from '@angular/http' ;
2
+ import { HTTP_PROVIDERS , Http , XHRBackend , ConnectionBackend , RequestOptions , RequestOptionsArgs , ResponseOptions , ResponseType , Response , XSRFStrategy } from '@angular/http' ;
3
3
import { Observable } from 'rxjs/Observable' ;
4
4
import 'rxjs/add/observable/fromPromise' ;
5
5
import { NSFileSystem } from '../file-system/ns-file-system' ;
@@ -8,7 +8,7 @@ export class NSXSRFStrategy {
8
8
public configureRequest ( req : any ) {
9
9
// noop
10
10
}
11
- }
11
+ }
12
12
13
13
@Injectable ( )
14
14
export class NSHttp extends Http {
@@ -20,12 +20,12 @@ export class NSHttp extends Http {
20
20
* Performs a request with `get` http method.
21
21
* Uses a local file if `~/` resource is requested.
22
22
*/
23
- get ( url : string , options ?: RequestOptionsArgs ) : Observable < Response | any > {
23
+ get ( url : string , options ?: RequestOptionsArgs ) : Observable < Response > {
24
24
if ( url . indexOf ( '~' ) === 0 || url . indexOf ( '/' ) === 0 ) {
25
25
// normalize url
26
26
url = url . replace ( '~' , '' ) . replace ( '/' , '' ) ;
27
27
// request from local app resources
28
- return Observable . fromPromise ( new Promise ( ( resolve , reject ) => {
28
+ return Observable . fromPromise < Response > ( new Promise ( ( resolve , reject ) => {
29
29
let app = this . nsFileSystem . currentApp ( ) ;
30
30
let localFile = app . getFile ( url ) ;
31
31
if ( localFile ) {
@@ -58,7 +58,8 @@ export const NS_HTTP_PROVIDERS: any[] = [
58
58
HTTP_PROVIDERS ,
59
59
{ provide : XSRFStrategy , useValue : new NSXSRFStrategy ( ) } ,
60
60
NSFileSystem ,
61
- { provide : Http , useFactory : ( backend , options , nsFileSystem ) => {
61
+ {
62
+ provide : Http , useFactory : ( backend , options , nsFileSystem ) => {
62
63
return new NSHttp ( backend , options , nsFileSystem ) ;
63
64
} , deps : [ XHRBackend , RequestOptions , NSFileSystem ]
64
65
}
0 commit comments