Skip to content

Commit

Permalink
bug(placeOrder): Fix async issue and load
Browse files Browse the repository at this point in the history
  • Loading branch information
bucharitesh committed Sep 12, 2022
1 parent 19fcd20 commit 2848875
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 38 deletions.
16 changes: 8 additions & 8 deletions dist/FlamSaasSDK.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dist/FlamSaasSDK.min.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/FlamSaasSDK.min.esm.js.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dist/FlamSaasSDK.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/vanilla-js/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous" />
<!-- flam sdk lib and css below -->
<script src="https://unpkg.com/[email protected]/dist/FlamSaasSDK.min.js"></script>
<!-- <script src="../../dist/FlamSaasSDK.js"></script> -->
<!-- <script src="https://unpkg.com/[email protected]/dist/FlamSaasSDK.min.js"></script> -->
<script src="../../dist/FlamSaasSDK.js"></script>

<!-- your javascript -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/boot=strap.min.js"
integrity="sha384-ODmDIVzN+pFdexxHEHFBQH3/9/vQ9uori45z4JjnFsRydbmQbmL5t1tQ0culUzyK"
crossorigin="anonymous"></script>
</head>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flamsdk",
"version": "1.0.0",
"version": "1.0.2",
"description": "flamSdk for saas",
"author": "bucharitesh",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const SDK_BASE_URL = 'https://saas-sdk-flam.vpercel.app';
const SDK_BASE_URL = 'https://saas-sdk-flam.vercel.app';
// const SDK_BASE_URL = 'http://localhost:3000';

export const PAGES = {
Expand Down
9 changes: 5 additions & 4 deletions src/placeOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import assert from './helper/assert';

// TODO: write the parameter descriptions

export default function placeOrder(order_details, callback) {
export default async function placeOrder(order_details, callback) {
try {
// validate client data
assert.check(
Expand Down Expand Up @@ -85,16 +85,17 @@ export default function placeOrder(order_details, callback) {
// render the success UI
let url = `${PAGES.main}`;
this.callback = callback;
this.renderWithRetry(url);
await this.renderWithRetry(url);
} catch (err) {
if (callback && typeof callback === 'function') {
// render error UI
let url = `${PAGES.error}/Something went wrong!`;
this.renderWithRetry(url);
await this.renderWithRetry(url);
// callback to client with error
callback({ code: 400, message: err.message }, null);
await callback({ code: 400, message: err.message }, null);
} else {
throw "'callback' is required function.";
}
}
document.activeElement.blur();
}
Loading

0 comments on commit 2848875

Please sign in to comment.