aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/Chat.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-06-27 14:33:34 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:53 +0300
commit40b8cd9853dd87deb90afdda0f5af78faa414f2b (patch)
treef4beb12efd422f178cfe168367ef91b17f6131b8 /vnext/src/components/Chat.js
parent8307e220c4fdddbc0a9740ad4b43fc2e205864bd (diff)
fetch -> axios
Diffstat (limited to 'vnext/src/components/Chat.js')
-rw-r--r--vnext/src/components/Chat.js24
1 files changed, 8 insertions, 16 deletions
diff --git a/vnext/src/components/Chat.js b/vnext/src/components/Chat.js
index 8f3a26c0..c7a5c3ff 100644
--- a/vnext/src/components/Chat.js
+++ b/vnext/src/components/Chat.js
@@ -4,6 +4,8 @@ import moment from 'moment';
import PM from './PM';
import MessageInput from './MessageInput';
+import { getChat, pm } from '../api';
+
export default class Chat extends React.Component {
constructor(props) {
super(props);
@@ -22,30 +24,20 @@ export default class Chat extends React.Component {
chats: []
});
if (hash && uname) {
- fetch(`https://api.juick.com/pm?uname=${uname}&hash=${hash}`)
- .then(response => response.json())
- .then(jsonResponse => {
+ getChat(uname)
+ .then(response => {
this.setState({
- chats: jsonResponse
+ chats: response.data
});
});
}
}
onSend = (template) => {
- const url = `https://api.juick.com/pm?hash=${this.props.visitor.hash}`;
- let form = new FormData();
- form.append('body', template.body);
- form.append('uname', template.to.uname);
- fetch(url, {
- method: 'POST',
- body: form
- }).then(response => {
- return response.json()
- }).then(res => {
+ pm(template.to.uname, template.body)
+ .then(res => {
this.loadChat(this.props.match.params.user);
- })
- .catch(console.log)
+ }).catch(console.log)
}
render() {