-
-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing adapter signature to receive config and return promises
- Loading branch information
1 parent
8f3a430
commit 157efd5
Showing
6 changed files
with
315 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,37 @@ | ||
# axios // adapters | ||
|
||
The modules under `adapters/` are modules that handle dispatching a request and settling a `Promise` once a response is received. | ||
The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received. | ||
|
||
## Example | ||
|
||
```js | ||
var settle = require('./../core/settle'); | ||
|
||
module.exports myAdapter(resolve, reject, config) { | ||
module.exports myAdapter(config) { | ||
// At this point: | ||
// - config has been merged with defaults | ||
// - request transformers have already run | ||
// - request interceptors have already run | ||
|
||
// Make the request using config provided | ||
// Upon response settle the Promise | ||
|
||
return new Promise(function(resolve, reject) { | ||
|
||
var response = { | ||
data: responseData, | ||
status: request.status, | ||
statusText: request.statusText, | ||
headers: responseHeaders, | ||
config: config, | ||
request: request | ||
}; | ||
var response = { | ||
data: responseData, | ||
status: request.status, | ||
statusText: request.statusText, | ||
headers: responseHeaders, | ||
config: config, | ||
request: request | ||
}; | ||
|
||
settle(resolve, reject, response); | ||
settle(resolve, reject, response); | ||
|
||
// From here: | ||
// - response transformers will run | ||
// - response interceptors will run | ||
// From here: | ||
// - response transformers will run | ||
// - response interceptors will run | ||
}); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.