Skip to content

NSHttp.get return type fixed #408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions nativescript-angular/http/ns-http.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Injectable} from '@angular/core';
import {HTTP_PROVIDERS, Http, XHRBackend, XHRConnection, ConnectionBackend, RequestOptions, RequestOptionsArgs, ResponseOptions, ResponseType, Response, Request, BrowserXhr, XSRFStrategy} from '@angular/http';
import {HTTP_PROVIDERS, Http, XHRBackend, ConnectionBackend, RequestOptions, RequestOptionsArgs, ResponseOptions, ResponseType, Response, XSRFStrategy} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/fromPromise';
import {NSFileSystem} from '../file-system/ns-file-system';
Expand All @@ -8,7 +8,7 @@ export class NSXSRFStrategy {
public configureRequest(req: any) {
// noop
}
}
}

@Injectable()
export class NSHttp extends Http {
Expand All @@ -20,12 +20,12 @@ export class NSHttp extends Http {
* Performs a request with `get` http method.
* Uses a local file if `~/` resource is requested.
*/
get(url: string, options?: RequestOptionsArgs): Observable<Response | any> {
get(url: string, options?: RequestOptionsArgs): Observable<Response> {
if (url.indexOf('~') === 0 || url.indexOf('/') === 0) {
// normalize url
url = url.replace('~', '').replace('/', '');
// request from local app resources
return Observable.fromPromise(new Promise((resolve, reject) => {
return Observable.fromPromise<Response>(new Promise((resolve, reject) => {
let app = this.nsFileSystem.currentApp();
let localFile = app.getFile(url);
if (localFile) {
Expand Down Expand Up @@ -58,7 +58,8 @@ export const NS_HTTP_PROVIDERS: any[] = [
HTTP_PROVIDERS,
{ provide: XSRFStrategy, useValue: new NSXSRFStrategy() },
NSFileSystem,
{ provide: Http, useFactory: (backend, options, nsFileSystem) => {
{
provide: Http, useFactory: (backend, options, nsFileSystem) => {
return new NSHttp(backend, options, nsFileSystem);
}, deps: [XHRBackend, RequestOptions, NSFileSystem]
}
Expand Down