imgs folder
This commit is contained in:
@@ -3,7 +3,7 @@ const preact = require('preact');
|
||||
const { Component } = require('preact')
|
||||
const { connect } = require('preact-redux');
|
||||
|
||||
const { postData } = require('../utils');
|
||||
const { postData, errorToast } = require('../utils');
|
||||
|
||||
const addState = connect(
|
||||
(state) => {
|
||||
@@ -12,14 +12,26 @@ const addState = connect(
|
||||
} = state;
|
||||
function submitLogin(name, password) {
|
||||
postData('/login', { name, password })
|
||||
.then(data => ws.connect())
|
||||
.catch(error => console.error(error));
|
||||
.then(res => {
|
||||
if (!res.ok) return errorToast(res);
|
||||
res.text()
|
||||
})
|
||||
.then(res => {
|
||||
ws.connect();
|
||||
})
|
||||
.catch(error => errorToast(error));
|
||||
}
|
||||
|
||||
function submitRegister(name, password, code) {
|
||||
postData('/register', { name, password, code })
|
||||
.then(data => ws.connect())
|
||||
.catch(error => console.error(error));
|
||||
.then(res => {
|
||||
if (!res.ok) return errorToast(res);
|
||||
res.text()
|
||||
})
|
||||
.then(res => {
|
||||
ws.connect();
|
||||
})
|
||||
.catch(error => errorToast(error));
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user