| |
@@ -4,7 +4,8 @@
|
| |
MAX_RETRY_LIMIT,
|
| |
FIRST_RETRY_GAP,
|
| |
} from "../constants/ProjectConstants"
|
| |
- import { endpoints } from "../constants/endpoints"
|
| |
+ import { landingPageApi } from "../api/landingPage"
|
| |
+ import { loadWizardDataApi } from "../api/wizard"
|
| |
|
| |
export const loadDataResp = (payload) => ({
|
| |
type: ActionTypes.LOAD_DATA_RESP,
|
| |
@@ -19,8 +20,7 @@
|
| |
payload: payload,
|
| |
})
|
| |
dispatch(updateLandingPageApiCallStatus(API_CALL_STATUS_VALUES.STARTED))
|
| |
- fetch(endpoints.landingPage)
|
| |
- .then((blob) => blob.json())
|
| |
+ landingPageApi()
|
| |
.then((data) => {
|
| |
dispatch(loadDataResp(data))
|
| |
dispatch(updateLandingPageApiCallStatus(API_CALL_STATUS_VALUES.FULFILLED))
|
| |
@@ -52,8 +52,7 @@
|
| |
payload: payload,
|
| |
})
|
| |
dispatch(updateWizardApiCallStatus(API_CALL_STATUS_VALUES.STARTED))
|
| |
- fetch(endpoints.allActions)
|
| |
- .then((blob) => blob.json())
|
| |
+ loadWizardDataApi()
|
| |
.then((data) => {
|
| |
dispatch(loadWizardDataResp(data))
|
| |
dispatch(updateWizardApiCallStatus(API_CALL_STATUS_VALUES.FULFILLED))
|
| |
This PR adds a new wrapper method
sendRequest()
for sending API calls/requests.Under the hood, it's using
fetch()
so in case we decide to move to any other utility to send API requests like Axios, SuperAgent, etc, all we've to do is make amendments in thesendRequest()
wrapper method instead of changing fetch from all files.From now on, if we've to create a new API request, we'll have to go in the following way ->
- Create a file in
/api/
if needed.- Add the
*Api()
method which calls thesendRequest()
method and return the same.-Catch errors wherever we're using the
*Api()
method.sendRequest()
supports the following this as of now-Where,
url
: is the URL where we've to make the request.method
: defaults to "GET", it can be any HTTP method.body
: is the body of the HTTP request in case we've to send it.queryParams
: In case we've to send any URL query param. It should be an object with key-value pairs.