Skip to content

Instantly share code, notes, and snippets.

@1998code
Created July 10, 2022 01:57
Show Gist options
  • Save 1998code/c81ad3f8a3d954ba14e9b9d82472bfaf to your computer and use it in GitHub Desktop.
Save 1998code/c81ad3f8a3d954ba14e9b9d82472bfaf to your computer and use it in GitHub Desktop.
Function of getDalle2
function getDalle2() {
setError(false);
setLoading(true);
fetch(`/api/dalle2?k=${token}&q=${query}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
})
.then((res) => res.json())
.then((data) => {
setResults(data.result);
setLoading(false);
})
.catch((err) => {
console.log(err);
setLoading(false);
setError(true);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment