Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Document stand-alone usage #135

Merged
merged 4 commits into from
Aug 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,44 @@ That's all the configuration required! If you want to customize the adapter, su

Note that instead of using the Ember Data error checking code in your application, you should use the ones provided by Ember AJAX.

## Stand-Alone Usage

If you aren't using Ember Data and do not have access to services, you
can import the ajax utility like so:

```js
import request from 'ember-ajax/request';

export default function someUtility(url) {
var options = {
// request options
};

return request(url, options).then(response => {
// `response` is the data from the server
return response;
});
}
```

Which will have the same API as the `ajax` service. If you want the raw jQuery XHR object
then you can use the `raw` method instead:

```js
import raw from 'ember-ajax/raw';

export default function someOtherUtility(url) {
var options = {
// raw options
};

return raw(url, options).then(result => {
// `result` is an object containing `response` and `jqXHR`, among other items
return result;
});
}
```

## Testing

### Fixture Data
Expand Down