-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(method): new 'requestModulesApi' method
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { _config } from '@ecomplus/utils' | ||
import { API_MODULES } from './../lib/constants' | ||
import request from './../lib/request' | ||
|
||
// returns axios request promise | ||
const requestModulesApi = ( | ||
url, | ||
method = 'get', | ||
data, | ||
storeId = _config.get('store_id'), | ||
axiosConfig | ||
) => request({ | ||
data, | ||
...axiosConfig, | ||
url, | ||
baseURL: API_MODULES, | ||
method, | ||
headers: { | ||
'X-Store-ID': storeId | ||
} | ||
}) | ||
|
||
/** | ||
* @method | ||
* @memberof ecomClient | ||
* @name requestModulesApi | ||
* @description Send HTTP GET request to | ||
* [E-Com Plus Modules REST API]{@link https://developers.e-com.plus/docs/api/#/modules/}. | ||
* | ||
* @param {string} url - API endpoint to request or absolute URI | ||
* @param {number} [storeId=_config.get('store_id')] - E-Com Plus Store ID number | ||
* @param {object} [axiosConfig] - Additional | ||
* [axios config]{@link https://github.com/axios/axios#request-config} settings | ||
* | ||
* @returns {Promise<response|error>} | ||
* Axios request promise resolved with | ||
* [response]{@link https://github.com/axios/axios#response-schema} | ||
* or rejected with | ||
* [error]{@link https://github.com/axios/axios#handling-errors}. | ||
* | ||
* @example | ||
// TODO | ||
*/ | ||
|
||
export default requestModulesApi |