I want to build a URL not trigger an ajax request for a non typical RESTful API. To extend the fruits example in the README I have a API endpoint
Example Rails API route:
config/routes.rb
Rails.application.routes.draw do
resources :fruits do
member do
get 'print' to: 'fruits#print'
end
end
end
app/models/fruit.js
import DS from 'ember-data';
import { memberUrl } from 'ember-api-actions';
const { attr } = DS;
export default DS.Model.extend({
uuid: attr('string'),
// /fruits/123UID/print
print: memberUrl({
path: 'print',
id: 'uuid',
}),
});
This print URL is then passed to a print service which handles getting the document to print from the URL and printing it (in my case via https://qz.io/)
myPrinterService.printDoc({ url: myRecord.print })
In the above example the record id in the URL is replaced with the record UUID as the endpoint is unauthenticated though should be hard to guess. Would you accept a PR for memberUrl @mike-north ?
I want to build a URL not trigger an ajax request for a non typical RESTful API. To extend the fruits example in the README I have a API endpoint
Example Rails API route:
config/routes.rb
app/models/fruit.js
This print URL is then passed to a print service which handles getting the document to print from the URL and printing it (in my case via https://qz.io/)
In the above example the record id in the URL is replaced with the record UUID as the endpoint is unauthenticated though should be hard to guess. Would you accept a PR for
memberUrl@mike-north ?