Skip to content

Commit

Permalink
fixed typo & added reading json response
Browse files Browse the repository at this point in the history
  • Loading branch information
zlatinametodieva committed Nov 19, 2021
1 parent 84550e8 commit 2fdcdb1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 138 deletions.
2 changes: 1 addition & 1 deletion api/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
});

module.exports = {
helloworld: util.format("http://helloworld%s",domain),
helloWorldUrl: util.format("http://helloworld%s",domain),
catalogueUrl: util.format("http://catalogue%s", domain),
tagsUrl: util.format("http://catalogue%s/tags", domain),
cartsUrl: util.format("http://carts%s/carts", domain),
Expand Down
30 changes: 4 additions & 26 deletions api/helloworld/index.js
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;
}());
}());
14 changes: 7 additions & 7 deletions public/helloworld.html
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>
103 changes: 1 addition & 102 deletions public/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</a>
</div>
<!--/.navbar-header -->
<div class="navbar-collapse collapse" id="navhelloworld">NavHelloworld</div>
<div class="navbar-collapse collapse" id="navhelloworld"></div>

<div class="navbar-collapse collapse" id="navigation">

Expand Down Expand Up @@ -78,82 +78,6 @@ <h5>Featured</h5>
</li>
<li id="tabAccount"><a href="customer-orders.html">Account</a>
</li>
<!--<li class="dropdown yamm-fw">-->
<!--<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="200">Template <b class="caret"></b></a>-->
<!--<ul class="dropdown-menu">-->
<!--<li>-->
<!--<div class="yamm-content">-->
<!--<div class="row">-->
<!--<div class="col-sm-3">-->
<!--<h5>Shop</h5>-->
<!--<ul>-->
<!--<li><a href="index.html">Homepage</a>-->
<!--</li>-->
<!--<li><a href="category.html">Category - sidebar left</a>-->
<!--</li>-->
<!--<li><a href="category-right.html">Category - sidebar right</a>-->
<!--</li>-->
<!--<li><a href="category-full.html">Category - full width</a>-->
<!--</li>-->
<!--<li><a href="detail.html">Product detail</a>-->
<!--</li>-->
<!--</ul>-->
<!--</div>-->
<!--<div class="col-sm-3">-->
<!--<h5>User</h5>-->
<!--<ul>-->
<!--<li><a href="register.html">Register / login</a>-->
<!--</li>-->
<!--<li><a href="customer-orders.html">Orders history</a>-->
<!--</li>-->
<!--<li><a href="customer-order.html">Order history detail</a>-->
<!--</li>-->
<!--<li><a href="customer-wishlist.html">Wishlist</a>-->
<!--</li>-->
<!--<li><a href="customer-account.html">Customer account / change password</a>-->
<!--</li>-->
<!--</ul>-->
<!--</div>-->
<!--<div class="col-sm-3">-->
<!--<h5>Order process</h5>-->
<!--<ul>-->
<!--<li><a href="basket.html">Shopping cart</a>-->
<!--</li>-->
<!--<li><a href="checkout1.html">Checkout - step 1</a>-->
<!--</li>-->
<!--<li><a href="checkout2.html">Checkout - step 2</a>-->
<!--</li>-->
<!--<li><a href="checkout3.html">Checkout - step 3</a>-->
<!--</li>-->
<!--<li><a href="checkout4.html">Checkout - step 4</a>-->
<!--</li>-->
<!--</ul>-->
<!--</div>-->
<!--<div class="col-sm-3">-->
<!--<h5>Pages and blog</h5>-->
<!--<ul>-->
<!--<li><a href="blog.html">Blog listing</a>-->
<!--</li>-->
<!--<li><a href="post.html">Blog Post</a>-->
<!--</li>-->
<!--<li><a href="faq.html">FAQ</a>-->
<!--</li>-->
<!--<li><a href="text.html">Text page</a>-->
<!--</li>-->
<!--<li><a href="text-right.html">Text page - right sidebar</a>-->
<!--</li>-->
<!--<li><a href="404.html">404 page</a>-->
<!--</li>-->
<!--<li><a href="contact.html">Contact</a>-->
<!--</li>-->
<!--</ul>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--&lt;!&ndash; /.yamm-content &ndash;&gt;-->
<!--</li>-->
<!--</ul>-->
<!--</li>-->
</ul>

</div>
Expand All @@ -166,32 +90,7 @@ <h5>Featured</h5>
class="fa fa-shopping-cart"></i><span class="hidden-sm"
id="numItemsInCart">0 items in cart</span></a>
</div>
<!--/.nav-collapse -->

<!--<div class="navbar-collapse collapse right" id="search-not-mobile">-->
<!--<button type="button" class="btn navbar-btn btn-primary" data-toggle="collapse" data-target="#search">-->
<!--<span class="sr-only">Toggle search</span>-->
<!--<i class="fa fa-search"></i>-->
<!--</button>-->
<!--</div>-->

</div>

<!--<div class="collapse clearfix" id="search">-->

<!--<form class="navbar-form" role="search">-->
<!--<div class="input-group">-->
<!--<input type="text" class="form-control" placeholder="Search">-->
<!--<span class="input-group-btn">-->

<!--<button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>-->

<!--</span>-->
<!--</div>-->
<!--</form>-->

<!--</div>-->

<!--/.nav-collapse -->

</div>
Expand Down
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var request = require("request")
, orders = require("./api/orders")
, user = require("./api/user")
, metrics = require("./api/metrics")
, go_hello_world = require("./api/helloworld")
, helloWorld = require("./api/helloworld")
, app = express()


Expand Down Expand Up @@ -52,7 +52,7 @@ app.use(cart);
app.use(catalogue);
app.use(orders);
app.use(user);
app.use(go_hello_world);
app.use(helloWorld);

app.use(helpers.errorHandler);

Expand Down

1 comment on commit 2fdcdb1

@curiousjaki
Copy link

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

Please sign in to comment.