Skip to content

Commit

Permalink
fix faucet CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
martinseanhunt committed Jul 20, 2021
1 parent 2c6b326 commit a75a896
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
11 changes: 3 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions src/components/SimpleFaucet.js
Expand Up @@ -4,25 +4,25 @@ import TextField from '@material-ui/core/TextField'
import Button from '@material-ui/core/Button'
import Box from '@material-ui/core/Box'

export default function SimpleFaucet () {
export default function SimpleFaucet() {
const {
value: address,
bind: bindAddress,
reset: resetAddress
reset: resetAddress,
} = useInput('')
const [ submitted, setSubmitted ] = useState(false)
const [ error, setError ] = useState(false)
const [ loading, setLoading ] = useState(false)
const [submitted, setSubmitted] = useState(false)
const [error, setError] = useState(false)
const [loading, setLoading] = useState(false)

const requestOptions = {
method: 'POST',
body: JSON.stringify({ address: `${address}` })
body: JSON.stringify({ address: `${address}` }),
}
const handleSubmit = (evt) => {
evt.preventDefault()
setLoading(true)
fetch(
'https://developers.cardano.org/api/submit-address',
'https://testnets.cardano.org/api/submit-address',
requestOptions
).then((response) => {
if (response.ok) {
Expand All @@ -37,10 +37,10 @@ export default function SimpleFaucet () {
})
}
return (
<Box maxWidth='40rem' marginTop={4} marginBottom={4} position='relative'>
<Box maxWidth="40rem" marginTop={4} marginBottom={4} position="relative">
<form onSubmit={handleSubmit}>
<Box marginBottom={2}>
<TextField required label='Address' fullWidth {...bindAddress} />
<TextField required label="Address" fullWidth {...bindAddress} />
</Box>
{submitted && (
<div style={{ color: 'green' }}>
Expand All @@ -52,12 +52,12 @@ export default function SimpleFaucet () {
There was a problem with the address input
</span>
)}
<Box display='flex' justifyContent='flex-end'>
<Box display="flex" justifyContent="flex-end">
<Button
value='submit'
type='submit'
color='primary'
variant='contained'
value="submit"
type="submit"
color="primary"
variant="contained"
disabled={loading}
>
{loading ? 'Loading...' : 'Request funds'}
Expand Down

0 comments on commit a75a896

Please sign in to comment.