Skip to content

Instantly share code, notes, and snippets.

@iamajvillalobos
Created November 4, 2018 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamajvillalobos/93619f0ec57fcca3fc18a3902a39b199 to your computer and use it in GitHub Desktop.
Save iamajvillalobos/93619f0ec57fcca3fc18a3902a39b199 to your computer and use it in GitHub Desktop.
import React from "react";
import axios from "axios";
const STELLAR_API_URL = "https://horizon.stellar.org/accounts";
function AddressCheckerButton({ address, onButtonClick, onError }) {
function fetchAddressBalances() {
const url = `${STELLAR_API_URL}/${address}`;
axios
.get(url)
.then(response => {
const balances = response.data.balances;
onButtonClick(balances);
onError(response.status);
})
.catch(error => {
onError(error.response.status);
});
}
return (
<div className="check-balance-button">
<button onClick={fetchAddressBalances}>Check Balance</button>
</div>
);
}
export default AddressCheckerButton;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment