convert promise to async await

This commit is contained in:
Barry Gitarts 2018-05-25 11:39:11 -04:00
parent 6553a44e45
commit ba0d641868
1 changed files with 15 additions and 16 deletions

View File

@ -60,11 +60,11 @@ const AddDomain = withFormik({
if (!domainName) errors.domainName = 'Required'; if (!domainName) errors.domainName = 'Required';
return errors; return errors;
}, },
handleSubmit(values, { setSubmitting }) { async handleSubmit(values, { setSubmitting }) {
const { domainName, domainPrice } = values const { domainName, domainPrice } = values
const { methods: { domains, addDomain, setDomainPrice } } = ENSSubdomainRegistry const { methods: { domains, addDomain, setDomainPrice } } = ENSSubdomainRegistry
const hashedDomain = hash(domainName); const hashedDomain = hash(domainName);
getDomain(hashedDomain, domains).then(({ state }) => { const { state } = await getDomain(hashedDomain, domains);
setPrice( setPrice(
!!state ? setDomainPrice : addDomain, !!state ? setDomainPrice : addDomain,
hashedDomain, hashedDomain,
@ -78,7 +78,6 @@ const AddDomain = withFormik({
setSubmitting(false); setSubmitting(false);
console.log(err); console.log(err);
}) })
})
} }
})(InnerForm) })(InnerForm)