Move some interactions to the backendInteractor
The idea is that all interactions should move there, so components don't have to pass around credentials all the time.
This commit is contained in:
parent
b1f9f6395c
commit
215e51f764
6 changed files with 50 additions and 9 deletions
|
@ -20,21 +20,23 @@ let fetch = (url, options) => {
|
|||
}
|
||||
|
||||
const authHeaders = (user) => {
|
||||
if (user) {
|
||||
if (user && user.username && user.password) {
|
||||
return { 'Authorization': `Basic ${btoa(`${user.username}:${user.password}`)}` }
|
||||
} else {
|
||||
return { }
|
||||
}
|
||||
}
|
||||
|
||||
const fetchConversation = ({id}) => {
|
||||
const fetchConversation = ({id, credentials}) => {
|
||||
let url = `${CONVERSATION_URL}/${id}.json?count=100`
|
||||
return fetch(url).then((data) => data.json())
|
||||
return fetch(url, { headers: authHeaders(credentials) })
|
||||
.then((data) => data.json())
|
||||
}
|
||||
|
||||
const fetchStatus = ({id}) => {
|
||||
const fetchStatus = ({id, credentials}) => {
|
||||
let url = `${STATUS_URL}/${id}.json`
|
||||
return fetch(url).then((data) => data.json())
|
||||
return fetch(url, { headers: authHeaders(credentials) })
|
||||
.then((data) => data.json())
|
||||
}
|
||||
|
||||
const fetchTimeline = ({timeline, credentials, since = false, until = false}) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue