Guest User

Untitled

a guest
Apr 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. export function* loadData() {
  2. console.log("Saga: Loading Data...");
  3. try {
  4. const response = yield call(request, requestURL,
  5. { method: 'GET', credentials: 'include', headers: {
  6. 'Content-Type': 'application/json', } });
  7. // Nothing past this point is ever touched :(
  8. if (response.success) {
  9. console.log("SUCCESS!!!!");
  10. ...
  11.  
  12. export default function request(url, options) {
  13. return fetch(url, options)
  14. .then(checkStatus)
  15. .then(parseJSON);
  16. }
  17.  
  18. function parseJSON(response) {
  19. if (response.status === 204 || response.status === 205) {
  20. return null;
  21. }
  22. var responseClone = response.clone();
  23. console.log(responseClone.json());
  24. return response.json();
  25. }
  26.  
  27. SAGA: Loading Data...
  28. [[PromiseStatus]]:"resolved"
  29. [[PromiseValue]]:Object
Add Comment
Please, Sign In to add comment