Adapt to Path Name Variations

Not only is there a means of changing the attribute names using JSONAPIAdapter, but you can alter the path to match as well. By default, Ember Data attempts to pluralize the name of the class to arrive at the API path, so a model class called notebook will use an endpoint path of notebooks. For any number of reasons, this may not be accurate. If so, you can use the pathForType method to address this need, like this:

 pathForType​:​ ​function​(type) {
 if​(type === ​'notebook'​)
 return​ ​'poorly-named-endpoint'​;
 }

As you can see, this method takes the model class name as an argument, and converts it into either a different value altogether or a somehow modified version of the name by changing the case, adding underscores, and so forth. This allows you to adapt to variations in naming conventions on the endpoint URL.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.162.26