Last active
May 21, 2018 06:10
-
-
Save teimurjan/57eaea0ec7b89837d796a5d3b8fcf6b2 to your computer and use it in GitHub Desktop.
blog-digits-recognizer-python-flask-react-3
This file contains 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 validateStatusCode = response => | |
new Promise((resolve, reject) => { | |
const status = response.status; | |
const next = status < 400 ? resolve : reject; | |
response.text().then(next); | |
}); | |
export const makePrediction = image => | |
fetch("/api/predict", { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json" | |
}, | |
body: JSON.stringify({ image }) | |
}).then(validateStatusCode); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment