forked from microservices-demo/front-end
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed typo & added reading json response
- Loading branch information
1 parent
84550e8
commit 2fdcdb1
Showing
5 changed files
with
15 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,14 @@ | ||
(function (){ | ||
'use strict'; | ||
|
||
var express = require("express") | ||
, request = require("request") | ||
, endpoints = require("../endpoints") | ||
, helpers = require("../../helpers") | ||
, app = express() | ||
|
||
app.get("/helloworld", function(req, res, next) { | ||
helpers.simpleHttpRequest(endpoints.helloworld, res, next); | ||
helpers.simpleHttpRequest(endpoints.helloWorldUrl, res, next); | ||
}); | ||
|
||
function helloworld(callback) { | ||
console.log("Requesting helloworld"); | ||
$.ajax({ | ||
url: "helloworld" + id, | ||
type: "GET", | ||
success: function (data, textStatus, jqXHR) { | ||
json = JSON.parse(data); | ||
if (json.status_code !== 500) { | ||
callback(json); | ||
} else { | ||
console.error('Could not get helloworld'); | ||
return callback("HelloWorld not Available"); | ||
} | ||
}, | ||
error: function (jqXHR, textStatus, errorThrown) { | ||
console.error('Error while retrieving helloworld'); | ||
return callback("HelloWorld Threw an Error"); | ||
} | ||
}); | ||
} | ||
|
||
module.exports = app; | ||
}()); | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<div id="hi">Calling helloworld? Answer: | ||
</div> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<div id="hi"></div> | ||
|
||
<script> | ||
$(document).ready(function () { | ||
$('#hi').append("Calling document Ready"); | ||
}); | ||
$.getJSON('/helloworld', {}, function (data) { | ||
$('hi').text(data); | ||
$('#hi').text(data.message); | ||
}).error(function () { | ||
$('#hi').text("Error on API Call."); | ||
}); | ||
</script> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2fdcdb1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, This is really useful :D