summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-18 22:24:03 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-18 22:24:03 +0800
commita7b4ce7e5a00927bf833efb84cca45e0bb94a7cc (patch)
tree6a60e04a8ce295e04530fe65d0c69d93589f1726
parent8673d6c9333682ec0ff298f19e917e7705524adb (diff)
It's not returning use
-rw-r--r--hooks/authenticatedFetch.js34
1 files changed, 16 insertions, 18 deletions
diff --git a/hooks/authenticatedFetch.js b/hooks/authenticatedFetch.js
index 4b57ff7..111bb8b 100644
--- a/hooks/authenticatedFetch.js
+++ b/hooks/authenticatedFetch.js
@@ -1,25 +1,23 @@
-function authenticatedFetch(uri, options) {
+async function authenticatedFetch(uri, options) {
var AppBridge = window['app-bridge'];
var app = AppBridge.createApp({
apiKey: '',
host: ''
});
var fetchFunction = window['app-bridge-utils'].authenticatedFetch(app);
- return async (uri, options) => {
- var response = await fetchFunction(uri, options);
- var headers = response.headers;
- if (headers.get("X-Shopify-API-Request-Failure-Reauthorize")
- === "1") {
- var authUrlHeader = headers.get(
- "X-Shopify-API-Request-Failure-Reauthorize-Url")
- || `/api/auth`;
- var Redirect = AppBridge.actions.Redirect;
- Redirect.create(app).dispatch(Redirect.Action.REMOTE,
- authUrlHeader.startsWith("/")
- ? `https://${window.location.host}${authUrlHeader}`
- : authUrlHeader
- );
- }
- return response;
- };
+ var response = await fetchFunction(uri, options);
+ var headers = response.headers;
+ if (headers.get("X-Shopify-API-Request-Failure-Reauthorize")
+ === "1") {
+ var authUrlHeader = headers.get(
+ "X-Shopify-API-Request-Failure-Reauthorize-Url")
+ || `/api/auth`;
+ var Redirect = AppBridge.actions.Redirect;
+ Redirect.create(app).dispatch(Redirect.Action.REMOTE,
+ authUrlHeader.startsWith("/")
+ ? `https://${window.location.host}${authUrlHeader}`
+ : authUrlHeader
+ );
+ }
+ return response;
}