I have a problem with ember in a custom endpoint and a component
I need to get data from the custom endpoint when using a simple findAll the component works perfect but the findAll not going to custom endpoint, When I use adapter ajax goes to the custom endpoint and then pushPayload the data to the store but the component does not work.
What is the best way to call to an custom endpoint from Ember?
Related
How can I use apollo to change selectionSet in field resolver through one resolver without using stitch and extend resolver?
I am using ember member API actions and was wondering how can response be normalized in such cases.
I have a model "users" with member action "postAddress". It is a post request which returns me a response. Now the problem I am facing is data is not normalized as returned data does not map to any store model. I know when we do a findAll and give a model, then ember automatically normalizes the data returned from API call. But in case of member actions, can anyone suggest how can data be normalized? (snake case to camel case).
ember-api-actions addon does not provide any serializer integration. There is an open issue about it. As discussed there you could manually push the response to store using pushPayload method of store service provided by Ember Data.
If you don't want to push the data into the store but just use a Serializer to normalize the response, you could do so by combining serializerFor() method of DS.Store and normalizeResponse() method of DS.Serializer.
I'm building an app using Ember and trying to talk to a back end API using Ember Data and writing custom adapters.
The API I am using is not RESTful or conform to JSONAPI standard. It has many endpoints that does not take in id but returns data for current user.
For instance I have 'getAccountData' api that returns account data of the current user. The returned data has "id" associated with it (user_id of the current user) but you don't pass in "id" when calling the api to get the data.
I tried implementing findRecord method in my custom adapter but "id" parameter is required and it complains if I just call this.get('store').findRecord('account-data').
I can pass in dummy id like this.get('store').findRecord('account-data', 1) but this seems wrong since the 'id' of returned data won't be 1.
Should I be using findAll or query instead? is there a way to do this in clean way?
You should use queryRecord. From the Ember docs:
This method makes a request for one record, where the id is not known
beforehand (if the id is known, use findRecord instead).
Need to post data/datas to ember route without showing in url ,
Optional parameters to route
As long as you don't specify the property as a query parameter you should be able to pass anything to the route and then on as a request without it showing in the Ember URL.
My understanding is that if a given route in an Ember app needs to grab data from the server to feed its model, we will either use Ember data with a RESTful API or just an AJAX request, and the request for model data will come from the Ember app to the server.
But what if I want the server itself, at the end of a server-side process, to ask the Ember app to display one of its routes by passing to it some data to be used as the route model?
Basically, a process on the Node-based server (with Express) ends up like so:
function(req,res) {
res.redirect("/#/someEmberAppRoute");
}
The req parameter carries some object that I want to pass to the Ember route in order to be used as a model for that route.
The way I ended up solving this problem was to store on the server the output of the server-side process and have the Ember route someEmberAppRoute's model send a GET request to the server to grab that output and feed its model, instead of trying to push it directly from the server to the client.