Skip to content

Commit

Permalink
sync JS
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Yuan <michael@secondstate.io>
  • Loading branch information
juntao committed Dec 19, 2024
1 parent 799e00c commit e8a61be
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions test/add_news.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
console.log("formData is:");
console.log(JSON.stringify(form_json));

saved = false;
fetch('https://pastor-insights-service.gaianet.ai/webhook/2iMg3xL5cGDgVoDjoNjE/save_message/' + form_json['passcode'], {
method: 'POST',
credentials: "include",
Expand All @@ -105,10 +104,24 @@
return response.json();

}).then(function(data) {

console.log(data);
if (data['status']) {
saved = true;
console.log("Set saved=true");
console.log("Sending message now");
fetch('https://pastor-insights-service.gaianet.ai/webhook/2iMg3xL5cGDgVoDjoNjE/send_message/' + form_json['passcode'] + '/' + form_json['profile'], {
method: 'GET',
credentials: "include"

}).then(function(response2) {
return response2.json();

}).then(function(data2) {
console.log(data2);
if (data2['status']) {
document.getElementById('send').innerHTML = "Done!";
}
});

} else {
var em = document.getElementById("errorMsg");
em.innerHTML = data['message'];
Expand All @@ -120,25 +133,6 @@
var em = document.getElementById("errorMsg");
em.style.display = "block";
});

console.log("Trying to start sending");
if (saved) {
console.log("Sending message now");
fetch('https://pastor-insights-service.gaianet.ai/webhook/2iMg3xL5cGDgVoDjoNjE/send_message/' + form_json['passcode'] + '/' + form_json['profile'], {
method: 'GET',
credentials: "include"

}).then(function(response) {
return response.json();

}).then(function(data) {
console.log(data);
if (data['status']) {
document.getElementById("form").style.display = "none";
document.getElementById("successMsg").style.display = "block";
}
});
}
}
</script>
</head>
Expand Down

0 comments on commit e8a61be

Please sign in to comment.