Skip to content

Why come up with a different http request api? #35

Closed

Description

@vjeux

I wonder why you implemented a new API to do http request instead of picking one that already exist? Also, require('http') conflicts with node require('http') and doesn't have the same interface.

Activity

  1. vjeux commented on Apr 5, 2015

    @vjeux
    Author
  2. ligaz commented on Apr 6, 2015

    @ligaz
    Contributor

    Hey @vjeux, very good questions 😄

    Http

    The core of the NativeScript HTTP API is the request function which has similar signature to the one found in Node.js but returns a Promise rather than taking a callback as argument. We took an early architectural decision to use Promises in all our async APIs so strictly following the Node's API was no go for us. Also the Node's http module has a lot of server side baggage with it like createServer and friends.

    Regarding the XMLHttpRequest we have provided a shim for it so all libraries using it will feel at home.

    About the fetch API - it was not emerging as standard when we designed our API but we can consider adopting it. Currently a pollyfill can be used.

    LocalStorage

    Our current local settings API doesn't feel very JavaScript-ish and we should definitely simplify it by mimicking the LocalStorage API. We already got that feedback 😸

    Requiring Node.js built-in modules

    We definitely want to enable to somehow require Node's built-in modules. What we currently have in mind is a RequireJS plugin style of requiring: require("node!http") but be aware that this is just loud thinking for now.

  3. pitaj commented on Apr 7, 2015

    @pitaj

    @ligaz

    require("node!http")

    Sounds good to me.

  4. enchev commented on Apr 14, 2015

    @enchev
    Contributor

    We've decided to rename our current module "local-settings" to "application-settings", to avoid any confusion in the future, and we will add additional "local-storage" module with the same API as WebStorage.

  5. ligaz commented on Apr 14, 2015

    @ligaz
    Contributor

    @enchev Are we going to expose a localStorage instance on the global object the way we do it for console, XMLHttpRequest, etc.?

  6. enchev commented on Apr 15, 2015

    @enchev
    Contributor

    @ligaz Yep, we can expose it!

  7. ligaz commented on Jul 30, 2015

    @ligaz
    Contributor

    Hey @vjeux,

    Last week we released version 1.2 of NativeScript which introduces the fetch API. It currently supports text, JSON and FormData contents. ArrayBuffer and Stream are about to follow as well.

  8. valentinstoychev commented on Jul 30, 2015

    @valentinstoychev
  9. vjeux commented on Jul 30, 2015

    @vjeux
    Author

    Sweet :)

  10. enchev commented on Aug 11, 2015

    @enchev
    Contributor

    I've created new issue for binary data support in both fetch and xhr and I'm closing this.

  11. added a commit that references this issue on Mar 20, 2019
  12. lock commented on Aug 31, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  13. locked and limited conversation to collaborators on Aug 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions