mirror of
https://git.youjo.love/youjo/youjo-fe.git
synced 2024-11-20 13:59:55 +01:00
Add status and conversation fetching to apiService.
This commit is contained in:
parent
a5f523922c
commit
18c11e405a
1 changed files with 16 additions and 6 deletions
|
@ -7,18 +7,16 @@ const FAVORITE_URL = '/api/favorites/create'
|
|||
const UNFAVORITE_URL = '/api/favorites/destroy'
|
||||
const RETWEET_URL = '/api/statuses/retweet'
|
||||
const STATUS_UPDATE_URL = '/api/statuses/update.json'
|
||||
const STATUS_URL = '/api/statuses/show'
|
||||
const MEDIA_UPLOAD_URL = '/api/statusnet/media/upload'
|
||||
// const CONVERSATION_URL = '/api/statusnet/conversation/';
|
||||
const CONVERSATION_URL = '/api/statusnet/conversation'
|
||||
|
||||
// const FORM_CONTENT_TYPE = {'Content-Type': 'application/x-www-form-urlencoded'};
|
||||
|
||||
// import { param, ajax } from 'jquery';
|
||||
// import { merge } from 'lodash';
|
||||
const oldfetch = window.fetch
|
||||
|
||||
let fetch = (url, options) => {
|
||||
const baseUrl = ''
|
||||
const fullUrl = baseUrl + url
|
||||
return window.fetch(fullUrl, options)
|
||||
return oldfetch(fullUrl, options)
|
||||
}
|
||||
|
||||
const authHeaders = (user) => {
|
||||
|
@ -29,6 +27,16 @@ const authHeaders = (user) => {
|
|||
}
|
||||
}
|
||||
|
||||
const fetchConversation = ({id}) => {
|
||||
let url = `${CONVERSATION_URL}/${id}.json?count=100`
|
||||
return fetch(url).then((data) => data.json())
|
||||
}
|
||||
|
||||
const fetchStatus = ({id}) => {
|
||||
let url = `${STATUS_URL}/${id}.json`
|
||||
return fetch(url).then((data) => data.json())
|
||||
}
|
||||
|
||||
const fetchTimeline = ({timeline, credentials, since = false, until = false}) => {
|
||||
const timelineUrls = {
|
||||
public: PUBLIC_TIMELINE_URL,
|
||||
|
@ -108,6 +116,8 @@ const uploadMedia = ({formData, credentials}) => {
|
|||
const apiService = {
|
||||
verifyCredentials,
|
||||
fetchTimeline,
|
||||
fetchConversation,
|
||||
fetchStatus,
|
||||
favorite,
|
||||
unfavorite,
|
||||
retweet,
|
||||
|
|
Loading…
Reference in a new issue