Last active
December 20, 2021 05:05
-
-
Save mirsahib/ee953c17c5484ed6da261f05e6f1bd0f to your computer and use it in GitHub Desktop.
Revisions
-
mirsahib revised this gist
Dec 20, 2021 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // createUser and readUser is only necessary for signup and sign in page const createUser = async (url, data) => { try { let response = await fetch(url, { @@ -14,6 +14,7 @@ const createUser = async (url, data) => { console.log(err); } } const readUser = async (url, data) => { try { let response = await fetch(url+'?email='+data.email+'&password='+data.password, { @@ -28,7 +29,7 @@ const readUser = async (url, data) => { console.log(err); } } //upload image with label data to realm const uploadData = async (url, data) => { try { let response = await fetch(url, { @@ -44,10 +45,10 @@ const uploadData = async (url, data) => { console.log(err); } } //upload image to cloudinary const uploadImage = async (url, uri) => { try { let base64Img = `data:image/jpg;base64,${uri}`//attach base64 image let imageData = { file: base64Img, upload_preset: "annotationImage" } let response = await fetch(url, { method: "POST", -
mirsahib created this gist
Dec 19, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ const createUser = async (url, data) => { try { let response = await fetch(url, { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json", }, body: JSON.stringify(data), }); return await response.json(); } catch (err) { console.log(err); } } const readUser = async (url, data) => { try { let response = await fetch(url+'?email='+data.email+'&password='+data.password, { method: "GET", headers: { Accept: "application/json", "Content-Type": "application/json", }, }); return await response.json(); } catch (err) { console.log(err); } } const uploadData = async (url, data) => { try { let response = await fetch(url, { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json", }, body: JSON.stringify(data), }); return await response.json(); } catch (err) { console.log(err); } } const uploadImage = async (url, uri) => { try { let base64Img = `data:image/jpg;base64,${uri}` let imageData = { file: base64Img, upload_preset: "annotationImage" } let response = await fetch(url, { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json", }, body: JSON.stringify(imageData), }); return await response.json(); } catch (err) { console.log(err); } } export { createUser, readUser, uploadData, uploadImage }