Skip to content

feat(Http): can optionally fetch local resources from app bundle with Http #286

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
Jun 23, 2016
Merged

feat(Http): can optionally fetch local resources from app bundle with Http #286

merged 1 commit into from
Jun 23, 2016

Conversation

NathanWalker
Copy link
Contributor

This provides a nice convenience for Angular developers; an easy way to fetch local files with Http from their app bundle just like they would local files in their web app using the same semantics as NativeScript XML Image src property.

this.http.get(`~/assets/data.json`)
      .map((response: Response) => response.json())
      .subscribe((results: string[]) => {
        // we have results!
      });

... is now possible 👍

@NathanWalker
Copy link
Contributor Author

This now has tests with helpful mocks 👍

@NathanWalker
Copy link
Contributor Author

NathanWalker commented Jun 22, 2016

As far as any debate around "is it right to allow Http module to request local files"… the main question is does Http allow local files to be requested from a web server, and the answer is ​_Yes_​. That’s how web devs see it… If a file is in their web app and it can be requested via XMLHttpRequest, which it can, the same expectation will be brought to their approach to {N}… they will want to be able to intutively request files from their app with Http. This was one of those things when I started with nativescript-angular, I just expected to work and didn’t understand why it didnt… since i am a hardened web dev.

Outside of those logical reasons… it is just convenient sugar… and devs love sugar… it’s what makes for a happier dev experience imo.

@NathanWalker
Copy link
Contributor Author

NathanWalker commented Jun 22, 2016

This PR also fixes the new error occuring for some folks with latest that's in rc2 and rc3 with Http

ORIGINAL EXCEPTION: Error: not implemented
ORIGINAL STACKTRACE:
Error: not implemented
    at NativeScriptDomAdapter.Parse5DomAdapter.getCookie (/data/data/org.nativescript.nativescriptweather/files/app/tns_modules/@angular/platform-server/src/parse5_adapter.js:612:68)

@vakrilov
Copy link
Contributor

👍

1 similar comment
@hdeshev
Copy link
Contributor

hdeshev commented Jun 23, 2016

👍

@vakrilov vakrilov merged commit 2935b3a into NativeScript:master Jun 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants