Last active
December 20, 2021 05:05
-
-
Save mirsahib/ee953c17c5484ed6da261f05e6f1bd0f to your computer and use it in GitHub Desktop.
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 characters
| 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 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment