github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/app/utils/json-with-default.js (about) 1 import { copy } from 'ember-copy'; 2 3 // Used with fetch. 4 // Fetch only goes into the promise catch if there is a network error. 5 // This means that handling a 4xx or 5xx error is the responsibility 6 // of the developer. 7 const jsonWithDefault = defaultResponse => res => 8 res.ok ? res.json() : copy(defaultResponse, true); 9 10 export default jsonWithDefault;