Skip to content

Instantly share code, notes, and snippets.

@Harasz
Created September 1, 2021 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Harasz/9664337091404ff860072381385dd2f3 to your computer and use it in GitHub Desktop.
Save Harasz/9664337091404ff860072381385dd2f3 to your computer and use it in GitHub Desktop.
const setSettings = async (productId) => {
setIsSetLoading(true);
try {
const token = await getSessionToken(app);
const res = await fetch("/settings", {
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-type": "text/plain",
},
body: JSON.stringify({ productId }),
});
const responseData = await res.json();
if (responseData.status === "OK_SETTINGS") {
setSettingsObj(responseData.data);
}
throw Error("Unknown settings status");
} catch (err) {
setError(err.message);
} finally {
setIsSetLoading(false);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment