-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
61 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import apiClientRequest from "@/lib/api" | ||
|
||
export const getConversionCache = async () => { | ||
const { data } = await apiClientRequest.get(`/conversion/cache`) | ||
export const getConversionCache = async (from, to) => { | ||
const { data } = await apiClientRequest.get(`/conversion/cache`, { | ||
params: { | ||
from, | ||
to | ||
} | ||
}) | ||
return data | ||
} |
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,37 @@ | ||
export default { | ||
data: () => ({ | ||
isLoading: false, | ||
isErrors: null | ||
}), | ||
|
||
computed: { | ||
loadingPlaceholder() { | ||
return this.isLoading ? "Loading Data..." : "" | ||
} | ||
}, | ||
|
||
methods: { | ||
/** | ||
* Dispatch wrapper that marks the action as loading & parses errors | ||
* @param action | ||
* @param args | ||
* @returns {Promise<*>} | ||
*/ | ||
async dispatch(action, ...args) { | ||
this.isLoading = true | ||
try { | ||
const response = await action.apply(this, args) | ||
|
||
return Promise.resolve(response) | ||
} catch (error) { | ||
this.isErrors = error | ||
|
||
console.error(`[${error?.response?.status}] Something went wrong, Please try again later!`) | ||
|
||
return Promise.reject(error) | ||
} finally { | ||
this.isLoading = false | ||
} | ||
} | ||
} | ||
} |
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
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
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