* v3.14.0

* fix: simplify config fetch interceptor implementation

* add `loadRemoteConfig` flag to requests

* v3.14.0
This commit is contained in:
kyle
2018-04-27 23:20:13 -07:00
committed by GitHub
parent 8cef3adfe6
commit 7049de6201
11 changed files with 43 additions and 104 deletions

View File

@@ -1,23 +1,14 @@
import { parseYamlConfig } from "./helpers"
export const downloadConfig = (url) => ({fn: { fetch }, getConfigs}) => {
const { requestInterceptor, responseInterceptor } = getConfigs()
let req = { url }
if(requestInterceptor) {
req = requestInterceptor(req)
}
export const downloadConfig = (req) => (system) => {
const {fn: { fetch }} = system
return fetch(req)
.then(res => {
if(res) {
return responseInterceptor(res)
}
return res
})
}
export const getConfigByUrl = (configUrl, cb)=> ({ specActions }) => {
if (configUrl) {
return specActions.downloadConfig(configUrl).then(next, next)
export const getConfigByUrl = (req, cb)=> ({ specActions }) => {
if (req) {
return specActions.downloadConfig(req).then(next, next)
}
function next(res) {
@@ -25,7 +16,7 @@ export const getConfigByUrl = (configUrl, cb)=> ({ specActions }) => {
specActions.updateLoadingStatus("failedConfig")
specActions.updateLoadingStatus("failedConfig")
specActions.updateUrl("")
console.error(res.statusText + " " + configUrl)
console.error(res.statusText + " " + req.url)
cb(null)
} else {
cb(parseYamlConfig(res.text))