Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ability to use optimisticScenario #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
homepage: "https://stape.io/"
documentation: "https://github.com/stape-io/json-http-request-tag"
versions:
- sha: 04af4fc614c3339c591ecb51dd8d4213ccb66bb6
changeNotes: Add ability to use OptimisticScenario
- sha: 0b3a021ec9d32f010abf212ca7f85da62637c9e7
changeNotes: Fix log name
- sha: a3dc2725e8396fbe2b8e10a839828d8a7949c985
Expand Down
11 changes: 6 additions & 5 deletions template.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ sendHttpRequest(data.url, (statusCode, headers, body) => {
'ResponseBody': body,
}));
}

if (statusCode >= 200 && statusCode < 300) {
data.gtmOnSuccess();
} else {
data.gtmOnFailure();
if (!data.useOptimisticScenario) {
if (statusCode >= 200 && statusCode < 300) {
data.gtmOnSuccess();
} else {
data.gtmOnFailure();
}
}
}, requestOptions, postBody);

Expand Down
18 changes: 13 additions & 5 deletions template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ ___TEMPLATE_PARAMETERS___
"checkboxText": "Put request object inside the array.",
"simpleValueType": true
},
{
"type": "CHECKBOX",
"name": "useOptimisticScenario",
"checkboxText": "Use Optimistic Scenario",
"simpleValueType": true,
"help": "The tag will call gtmOnSuccess() without waiting for a response from the API"
},
{
"type": "GROUP",
"name": "requestData",
Expand Down Expand Up @@ -288,11 +295,12 @@ sendHttpRequest(data.url, (statusCode, headers, body) => {
'ResponseBody': body,
}));
}

if (statusCode >= 200 && statusCode < 300) {
data.gtmOnSuccess();
} else {
data.gtmOnFailure();
if (!data.useOptimisticScenario) {
if (statusCode >= 200 && statusCode < 300) {
data.gtmOnSuccess();
} else {
data.gtmOnFailure();
}
}
}, requestOptions, postBody);

Expand Down