Skip to content

Commit

Permalink
fix: error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ieow committed Mar 3, 2022
1 parent 29b13f3 commit b1d3ba3
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/components/topup/gateways/Moonpay.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup lang="ts">
import { get } from "@toruslabs/http-helpers";
import { helpers, maxValue, minValue, required } from "@vuelidate/validators";
import log from "loglevel";
import { TOPUP } from "@/plugins/Topup/interface";
Expand All @@ -11,27 +10,23 @@ import { RequestObject } from "./types";
async function getQuote(requestObject: RequestObject): Promise<QuoteResponse> {
let response: any;
try {
const options = {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
};
// response = await get(
// `${config.moonpayApiQuoteHost}/v3/currencies/ask_price?cryptoCurrencies=${requestObject.digital_currency}&apiKey=${config.moonpayTestAPIKEY}` +
// `&fiatCurrency=${requestObject.fiat_currency}&areFeesIncluded=true`,
response = await get(
`${config.moonpayApiQuoteHost}/v3/currencies/${requestObject.digital_currency}/buy_quote?apiKey=${config.moonpayLiveAPIKEY}` +
`&baseCurrencyCode=${requestObject.fiat_currency.toLowerCase()}&baseCurrencyAmount=${requestObject.requested_amount}&areFeesIncluded=true`,
options
);
} catch (error) {
log.error(error);
// throw await error.json();
throw await error;
const res = await (error as Response).json();
throw new Error(res.message);
}
// log.info(response);
return {
fee: response.feeAmount + response.networkFeeAmount + response.extraFeeAmount,
Expand Down

0 comments on commit b1d3ba3

Please sign in to comment.