Skip to content

Commit

Permalink
Updated spec with retry
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-qa007 committed Oct 3, 2024
1 parent 0ab5d31 commit 20018d4
Showing 1 changed file with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,29 @@ describe("Tests fetch calls", { tags: ["@tag.JS"] }, () => {
propPane.TypeTextIntoField("Label", "getUserName");
propPane.EnterJSContext(
"onClick",
`{{fetch('http://host.docker.internal:5001/v1/genderize_agify?name=sagar')
.then(res => {
if (!res.ok) {
throw new Error('Network response was not ok');
}
return res.json();
})
.then(json => {
const name = json.name; // Get the name
showAlert("Name: " + name);
})
.catch(error => {
console.error("Fetch error:", error);
showAlert("Failed to fetch user data: " + error.message);
})}}`,
`{{
(function fetchData(retries = 3) {
return fetch('http://host.docker.internal:5001/v1/genderize_agify?name=sagar')
.then(res => {
if (!res.ok) {
throw new Error('Network response was not ok');
}
return res.json();
})
.then(json => {
const name = json.name;
showAlert("Name: " + name);
})
.catch(error => {
if (retries > 0) {
return fetchData(retries - 1);
} else {
console.error("Fetch error:", error);
showAlert("Failed to fetch user data: " + error.message);
}
});
})()
}}`,
);

agHelper.Sleep(2000);
Expand Down

0 comments on commit 20018d4

Please sign in to comment.