|
|
|
@ -3,9 +3,9 @@ import debounce from 'lodash.debounce'
|
|
|
|
|
import omitBy from 'lodash.omitby'
|
|
|
|
|
import ms from 'ms'
|
|
|
|
|
|
|
|
|
|
import { DEFAULT_CODE, DEFAULT_SETTINGS } from './constants'
|
|
|
|
|
|
|
|
|
|
import { fileToDataURL } from './util'
|
|
|
|
|
import firebase from './client'
|
|
|
|
|
import { DEFAULT_CODE, DEFAULT_SETTINGS } from './constants'
|
|
|
|
|
|
|
|
|
|
export const client = axios.create({
|
|
|
|
|
baseURL: `${process.env.API_URL || ''}/api`,
|
|
|
|
@ -83,19 +83,27 @@ function getSnippet(uid = '', { host } = {}) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function listSnippets(page, headers) {
|
|
|
|
|
return client
|
|
|
|
|
function listSnippets(page) {
|
|
|
|
|
// IDEA: move into axios interceptor
|
|
|
|
|
return firebase
|
|
|
|
|
.auth()
|
|
|
|
|
.currentUser.getIdToken()
|
|
|
|
|
.then(authorization =>
|
|
|
|
|
client
|
|
|
|
|
.get(`/snippets`, {
|
|
|
|
|
params: {
|
|
|
|
|
page
|
|
|
|
|
},
|
|
|
|
|
headers
|
|
|
|
|
headers: {
|
|
|
|
|
authorization
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(res => res.data)
|
|
|
|
|
.catch(e => {
|
|
|
|
|
console.error(e)
|
|
|
|
|
throw e
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isNotDefaultSetting(v, k) {
|
|
|
|
|