import { Observable } from 'rxjs/Observable'
import 'rxjs/add/observable/fromPromise'
import 'rxjs/add/operator/mergeMap'

global.self = global
require('imports?this=>global!exports?global.fetch!isomorphic-fetch')

export default function fetchJSON(url) {
  return Observable.fromPromise(fetch(url))
    .mergeMap(response => response.json())
}

@@ -323,23 +323,338 @@
  =%3E 
-response.json()
+%7B%0A      const contentType = response.headers.get('content-type')%0A      if (contentType && contentType.indexOf('application/json') !== -1) %7B%0A        return response.json()%0A      %7D else %7B%0A        return response.text().then(resp =%3E (%7B%0A          error: 'Response was not json',%0A          responseBody: resp,%0A        %7D))%0A      %7D%0A    %7D
 )%0A%7D%0A

Handle non-json in authEndpoint (#553)