Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. export default function loader(index, default_type = 'profile') {
  2. let isHaveSlash = /\//.test(index);
  3. let isFullURL = /(http)/.test(index);
  4.  
  5. if(isFullURL) {
  6. Hooks.consoleLog(`${TAG} Checking Image URL`, index);
  7. return {uri: index};
  8. //fetch(index).then((res) => {
  9. // if(res.status == HTTP_STATUS.OK)
  10. // isHttpOK = true;
  11. // else
  12. // isHttpOK = false;
  13.  
  14. // Hooks.consoleLog(`${TAG} Image URL Status`, isHttpOK);
  15. //}).catch((err) => {
  16. // isHttpOK = false;
  17. //});
  18. }
  19.  
  20. if (!index || (isHaveSlash && !isFullURL) || (isFullURL && !isHttpOK)) {
  21. isHttpOK = true; // Revert back the value of isHttpOK
  22. return fetchObject(`${default_type}_default`); // as Default Image
  23. } else if (isFullURL) {
  24. return { uri: index };
  25. } else {
  26. let imgValue = fetchObject(index);
  27. return imgValue;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement