all files / apis/ dataService.js

95.45% Statements 21/22
75% Branches 6/8
100% Functions 2/2
92.31% Lines 12/13
1 branch Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                    
import fetch from 'isomorphic-fetch'
import fetchPlus from 'fetch-plus'
import plusJson from 'fetch-plus-json'
import plusBearerauth from 'fetch-plus-bearerauth'
 
const serviceUrl = () => {
  Iif (__SERVER__) {
    //return 'http://jsonplaceholder.typicode.com'
    return 'http://localhost:8000/api-proxy'
  }
  Eif (__CLIENT__) {
    const { protocol, hostname, port } = window.location
    return `${protocol}//${hostname}:${port}/api-proxy`
  }
}
 
const endpoint = fetchPlus.connectEndpoint(serviceUrl())
endpoint.addMiddleware(plusJson())
 
module.exports = endpoint