From 40b8cd9853dd87deb90afdda0f5af78faa414f2b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 27 Jun 2018 14:33:34 +0300 Subject: fetch -> axios --- vnext/src/components/LoginButton.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'vnext/src/components/LoginButton.js') 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); -- cgit v1.2.3