aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/Thread.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/Thread.js
parent8307e220c4fdddbc0a9740ad4b43fc2e205864bd (diff)
fetch -> axios
Diffstat (limited to 'vnext/src/components/Thread.js')
-rw-r--r--vnext/src/components/Thread.js26
1 files changed, 7 insertions, 19 deletions
diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js
index 17c5b55c..b1e1abb3 100644
--- a/vnext/src/components/Thread.js
+++ b/vnext/src/components/Thread.js
@@ -12,6 +12,8 @@ import Button from './Button';
import { format } from '../utils/embed';
+import { getMessages, comment } from '../api';
+
export default class Thread extends React.Component {
constructor(props) {
super(props);
@@ -36,16 +38,12 @@ export default class Thread extends React.Component {
if (this.props.visitor && this.props.visitor.hash) {
params.hash = this.props.visitor.hash
};
- const url = `https://api.juick.com/thread?${qs.stringify(params)}`;
- fetch(url)
+ getMessages('/thread', params)
.then(response => {
- return response.json()
- })
- .then(data => {
- let msg = data.shift();
+ let msg = response.data.shift();
this.setState({
msg: msg,
- replies: data,
+ replies: response.data,
active: 0
})
}
@@ -62,18 +60,8 @@ export default class Thread extends React.Component {
})
}
postComment = (template) => {
- const url = `https://api.juick.com/comment?hash=${this.props.visitor.hash}`;
- let form = new FormData();
- form.append('mid', template.mid);
- form.append('rid', template.rid);
- form.append('body', template.body);
- form.append('attach', template.attach);
- fetch(url, {
- method: 'POST',
- body: form
- }).then(response => {
- return response.json()
- }).then(res => {
+ const { mid, rid, body, attach } = template;
+ comment(mid, rid, body, attach).then(res => {
this.loadReplies()
})
.catch(console.log)