You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Why come up with a different http request api? #35
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.
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.
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.
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.
Activity
vjeux commentedon Apr 5, 2015
Same question for local-settings instead of localStorage?
ligaz commentedon Apr 6, 2015
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
createServerand 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.pitaj commentedon Apr 7, 2015
@ligaz
Sounds good to me.
enchev commentedon Apr 14, 2015
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.
ligaz commentedon Apr 14, 2015
@enchev Are we going to expose a
localStorageinstance on theglobalobject the way we do it forconsole,XMLHttpRequest, etc.?enchev commentedon Apr 15, 2015
@ligaz Yep, we can expose it!
ligaz commentedon Jul 30, 2015
Hey @vjeux,
Last week we released version 1.2 of NativeScript which introduces the
fetchAPI. It currently supports text, JSON and FormData contents. ArrayBuffer and Stream are about to follow as well.valentinstoychev commentedon Jul 30, 2015
It is here - http://docs.nativescript.org/ApiReference/fetch/HOW-TO.html
vjeux commentedon Jul 30, 2015
Sweet :)
enchev commentedon Aug 11, 2015
I've created new issue for binary data support in both fetch and xhr and I'm closing this.
Merge pull request #35 from NativeScript/vchimev-patch
lock commentedon Aug 31, 2019
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.