@commercetools/frontend-sdk
Advanced tools
Comparing version 1.0.7-alpha.0 to 1.1.0-alpha.0
## Version 1.1.0-alpha.0 (2022-12-05) | ||
* Added error handling | ||
## Version 1.0.7-alpha.0 (2022-12-05) | ||
@@ -3,0 +11,0 @@ |
{ | ||
"name": "@commercetools/frontend-sdk", | ||
"version": "1.0.7-alpha.0", | ||
"version": "1.1.0-alpha.0", | ||
"license": "UNLICENSED", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -99,3 +99,3 @@ import { fetcher } from "../helpers/fetcher"; | ||
} | ||
): Promise<T> { | ||
): Promise<T | Error> { | ||
this.#throwIfNotConfigured(); | ||
@@ -113,15 +113,23 @@ let params = ""; | ||
} | ||
return await this.#actionQueue.add<T>(() => { | ||
return fetcher<T>( | ||
this.#normaliseUrl(`${this.#endpoint}/frontastic/action/${actionName}${params}`), | ||
{ | ||
method: "POST", | ||
body: JSON.stringify(payload), | ||
headers: { | ||
'Frontastic-Locale': this.APILocale, | ||
//'Commercetools-Locale': this.APILocale // TODO: unsupported, needs backend work | ||
} | ||
}, | ||
); | ||
}); | ||
try { | ||
const result = await this.#actionQueue.add<T>(() => { | ||
return fetcher<T>( | ||
this.#normaliseUrl(`${this.#endpoint}/frontastic/action/${actionName}${params}`), | ||
{ | ||
method: "POST", | ||
body: JSON.stringify(payload), | ||
headers: { | ||
'Frontastic-Locale': this.APILocale, | ||
//'Commercetools-Locale': this.APILocale // TODO: unsupported, needs backend work | ||
} | ||
}, | ||
); | ||
}); | ||
return result; | ||
} catch (error) { | ||
if (typeof error === "string") { | ||
return new Error(error); | ||
} | ||
return error as Error; | ||
} | ||
} | ||
@@ -139,7 +147,15 @@ | ||
return fetcher<T>( | ||
this.#normaliseUrl(`${this.#endpoint}/page`), | ||
options | ||
) | ||
try { | ||
const result = fetcher<T>( | ||
this.#normaliseUrl(`${this.#endpoint}/page`), | ||
options | ||
); | ||
return result | ||
} catch (error) { | ||
if (typeof error === "string") { | ||
return new Error(error); | ||
} | ||
return error as Error; | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18320
624