forked from PacktPublishing/Cloud-Native-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI.jsx
More file actions
29 lines (28 loc) · 777 Bytes
/
Copy pathAPI.jsx
File metadata and controls
29 lines (28 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import SActions from './actions/SActions';
export default{
getAllTweets(){
// console.log(2, "API get tweets");
let str = "/api/v2/tweets/" + localStorage.getItem("sessionid")
$.getJSON(str , function(tweetModels) {
var t = tweetModels
SActions.recievedTweets(t)
});
},
addTweet(body, user){
$.ajax({
url: '/api/v2/tweets',
contentType: 'application/json',
type: 'POST',
data: JSON.stringify({
'username': localStorage.getItem("sessionid"),
'body': body,
}),
success: function() {
rawTweet => SActions.recievedTweet({ tweetedby: user,body: tweet, timestamp: Date.now})
},
error: function() {
return console.log("Failed");
}
});
}
}