diff options
author | Vitaly Takmazov | 2018-06-27 14:33:34 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:53 +0300 |
commit | 40b8cd9853dd87deb90afdda0f5af78faa414f2b (patch) | |
tree | f4beb12efd422f178cfe168367ef91b17f6131b8 /vnext/src/components/LoginButton.js | |
parent | 8307e220c4fdddbc0a9740ad4b43fc2e205864bd (diff) |
fetch -> axios
Diffstat (limited to 'vnext/src/components/LoginButton.js')
-rw-r--r-- | vnext/src/components/LoginButton.js | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/vnext/src/components/LoginButton.js b/vnext/src/components/LoginButton.js index fb3c087e..fbce6982 100644 --- a/vnext/src/components/LoginButton.js +++ b/vnext/src/components/LoginButton.js @@ -3,6 +3,8 @@ import PropTypes from 'prop-types'; import Icon from './Icon'; import Modal from './Modal'; +import { auth } from '../api'; + export default class LoginButton extends React.Component { constructor(props) { super(props); @@ -30,18 +32,10 @@ export default class LoginButton extends React.Component { } login = (event) => { event.preventDefault(); - let headers = new Headers(); - headers.append('Authorization', 'Basic ' + window.btoa(unescape(encodeURIComponent(this.state.username + ":" + this.state.password)))); - fetch('https://api.juick.com/auth', { - method: 'GET', - credentials: 'omit', - headers: headers - }).then(response => { - return response.text() - }) - .then(data => { + auth(this.state.username, this.state.password) + .then(response => { this.toggleModal(); - this.props.onAuth(data); + this.props.onAuth(response); } ).catch(ex => { console.log(ex); |