Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default function loader(index, default_type = 'profile') {
- let isHaveSlash = /\//.test(index);
- let isFullURL = /(http)/.test(index);
- if(isFullURL) {
- Hooks.consoleLog(`${TAG} Checking Image URL`, index);
- return {uri: index};
- //fetch(index).then((res) => {
- // if(res.status == HTTP_STATUS.OK)
- // isHttpOK = true;
- // else
- // isHttpOK = false;
- // Hooks.consoleLog(`${TAG} Image URL Status`, isHttpOK);
- //}).catch((err) => {
- // isHttpOK = false;
- //});
- }
- if (!index || (isHaveSlash && !isFullURL) || (isFullURL && !isHttpOK)) {
- isHttpOK = true; // Revert back the value of isHttpOK
- return fetchObject(`${default_type}_default`); // as Default Image
- } else if (isFullURL) {
- return { uri: index };
- } else {
- let imgValue = fetchObject(index);
- return imgValue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement