I was wondering if it's possible to get a remote JSON object using lodash, I've searched; however, what I've found is either you can do it in jQuery or purely in JS (of course it can be done using Angular, Backbone.js, etc..) but I haven't found anything related to lodash.
No
Lodash is a library for working with arrays, objects and functions. It has some basic template features and utilities but no features for making web requests.
See XMLHttpRequest:
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
You can do a lot without Lodash
https://www.npmjs.com/package/you-dont-need-lodash-underscore
And if you want an AJAX library. Here's the world's smallest:
https://github.com/yanatan16/nanoajax
Related
Is there a standard out-of-the-box way to access an API using GET or POST in TypeScript?
I only find libaries that do that like fetch or superagent suggested here when using React or HttpClient suggested here when using React.
I wonder though if there is a plain an simple way from within TypeScript to consume a REST API.
I wonder though if there is a plain an simple way from within TypeScript to consume a REST API.
Lets simplify REST API to be *I want to make GET and POST requests. The fact that it is a REST style API is not relevant.
I want to make GET and POST requests
Native ways of doing this depends on the JavaScript environment. e.g. Browser's traditional API has been XMLHttpRqeuest : https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest which is fully supported by TypeScript. A newer API is fetch which is also supported by TypeScript but might not be supported by the browser you are targetting.
On node you would use http module https://nodejs.org/api/http.html
Suggestion
Now if you want an API that works across both node and old browsers you will need some library that abstracts the native features. One suggestion is axios which works with TypeScript out of the box.
So one of the neat features of languages like PHP is that you can include other files pragmatically and make a plugin-like system. I haven't seen an example of it yet, so I am not sure it is technically possible in Dart, but I would like to start designing a CMS that can load and unload plugins live without restarting or a fresh upload.
Currently it is only possible to load/unload code dynamically using Isolates.
In the browser new isolates don't have access to the DOM and it is limited which types can be passed between isolates. What can be serialized to JSON can be passed between isolates easily but for custom types you need to serialize yourself. I'm not sure about the actual limitations here though, this is work in progress.
In the browser the current limitations make it hard to make use of isolates. You can't load code into an isolate that imports 'dart:html' this prevents the use any browser API. On the server there are no such limitations.
This should all be improved but currently there are still a lot of limitations.
So far I built most of my UI and logic in QML with JavaScript without touching the C++. But now I need to make a RESTFul API call, based upon the examples I saw so far I must write the call code in C++ then "some how" (Am still figuring out that part) get it in the QML/JavaScript world....
Can't i make the API call etc completely etc in QML/JavaScript?
I am not an expert in REST but in theory if you could write the call in JavaScript running in a browser, you should be able to make the the same call using very similar JavaScript in QML/JS.
Having said that one of the things you want to do to maintain the responsiveness of your application is not run any time consuming routines on the event thread. Ensuring this is the case is quite easy in C++, I'm nos sure you could do that as easily in JS.
Finally it is relatively easy to get the results back to JavaScript world is quite easy. Qt and Cascades has a rich data modeling component set. QVariantList and QVariantMap types map into JS arrays.
Is it possible in GWT 2.4+ to disable obfuscation for certain java model classes?
The reason I am asking this question is we use GWT RPC to talk to the server and need to store these objects returned etc in local storage using the Indexed DB API, we are currently using websql api. If GWT obfuscates/renames your properties etc then this renders using the Indexed DB API useless in your code.
Maybe there is a way to ask GWT to replace a property string with the obfuscated version in your Indexed DB api queries?
I could create a whole new java model that uses javascript overlays so these are preserved when GWT compiled and replace GWT RPC with JSON RPC but this would be a lot of work.
Any other ideas would be appreciated!
I also looked at the AutoBean framework which produces nice JSON output of your model interfaces but I don't think has a nice simple javascript representation under the hood.
You can set GWT Compile style attribute to PRETTY or DETAILED. so that GWT will not replace the class, method or variable names. For more information refer this link.
From all the various examples of Ember.js, I have not been able to figure out if there is a default method in Ember.js to do REST AJAX calls. Many examples build their own interfaces for CRUD operations. I even tried to sift through the code to find any reference to AJAX calls but came up with nothing.
So, my question is, is there a default implementation of REST API in Ember.js. If yes, how do I use it? Also if, for a specific application, I want to build custom CRUD methods, where do I plug these into Ember.js?
It seems that Ember Data is what you are looking for. It is part of emberjs organiztion in GitHub.
[2014-02-18: Deprecated - I no longer support ember-rest because it is overly simplistic, and would recommend using ember-data for most ember projects. Check out the Ember guides for an overview of ember-data as well as this example project ]
While learning Ember, I decided to create a very simple Ember REST library. I also wrote an example Rails CRUD app.
My goals were to keep this project as simple as possible, while still including error handling and validation. Ember REST is certainly much leaner than Ember Data and Ember Resource, and I hope you'll find the code well commented and accessible.
There is a Ember Resource library aiming REST JSON interfaces. It provides Ember.Resource class with save(), fetch() and destroy() operations that could be easily overriden. Looks like it should be more mature than Ember Data for now.
Ember.js can work nicely with Ember Data. That said, there is a specific format of REST to follow. When followed, you can streamline the process of connecting API with Ember and have so much less work.
In case you use custom REST, the place to adjust is:
adapter - to inform from where you like to get data
serializer - how data should be adjusted for custom REST API