JSON and Nodemon Functionality
I am trying to output the string "translations" when /translations is called, but this is not displayed in the browser.
const http = Noderequire('http');
const hostname = 'localhost';
const port = 3000;
const server = http.createServer((req, res) =>
const url = (req);
console.log(url);
if (url === '/ translations')
res.end ('translations');
res.end('Hi Chris, Welcome too Node!');
);
Thanks for helping out.
javascript node.js
add a comment |
I am trying to output the string "translations" when /translations is called, but this is not displayed in the browser.
const http = Noderequire('http');
const hostname = 'localhost';
const port = 3000;
const server = http.createServer((req, res) =>
const url = (req);
console.log(url);
if (url === '/ translations')
res.end ('translations');
res.end('Hi Chris, Welcome too Node!');
);
Thanks for helping out.
javascript node.js
What does this have to do with nodemon? Can your share the rest of the file/code for this? You also may have an extra space in '/ translations'.
– Rastalamm
Nov 14 '18 at 19:19
Here is the remaining piece of code below. Nodemon allows us to automatically restart the server when ever we update our application and hit save. I have also removed the extra space in '/translations'. and still is not working.
– Christopher A.
Nov 14 '18 at 19:52
server.listen(port, hostname, () => console.log(Server running at $hostname:$port); );
– Christopher A.
Nov 14 '18 at 19:52
I removed the extra space and I am gettingtranslationswhen queryinglocalhost:3000/translations
– Rastalamm
Nov 14 '18 at 19:57
add a comment |
I am trying to output the string "translations" when /translations is called, but this is not displayed in the browser.
const http = Noderequire('http');
const hostname = 'localhost';
const port = 3000;
const server = http.createServer((req, res) =>
const url = (req);
console.log(url);
if (url === '/ translations')
res.end ('translations');
res.end('Hi Chris, Welcome too Node!');
);
Thanks for helping out.
javascript node.js
I am trying to output the string "translations" when /translations is called, but this is not displayed in the browser.
const http = Noderequire('http');
const hostname = 'localhost';
const port = 3000;
const server = http.createServer((req, res) =>
const url = (req);
console.log(url);
if (url === '/ translations')
res.end ('translations');
res.end('Hi Chris, Welcome too Node!');
);
Thanks for helping out.
javascript node.js
javascript node.js
edited Nov 15 '18 at 1:33
Graham
3,637143659
3,637143659
asked Nov 14 '18 at 18:45
Christopher A.Christopher A.
12
12
What does this have to do with nodemon? Can your share the rest of the file/code for this? You also may have an extra space in '/ translations'.
– Rastalamm
Nov 14 '18 at 19:19
Here is the remaining piece of code below. Nodemon allows us to automatically restart the server when ever we update our application and hit save. I have also removed the extra space in '/translations'. and still is not working.
– Christopher A.
Nov 14 '18 at 19:52
server.listen(port, hostname, () => console.log(Server running at $hostname:$port); );
– Christopher A.
Nov 14 '18 at 19:52
I removed the extra space and I am gettingtranslationswhen queryinglocalhost:3000/translations
– Rastalamm
Nov 14 '18 at 19:57
add a comment |
What does this have to do with nodemon? Can your share the rest of the file/code for this? You also may have an extra space in '/ translations'.
– Rastalamm
Nov 14 '18 at 19:19
Here is the remaining piece of code below. Nodemon allows us to automatically restart the server when ever we update our application and hit save. I have also removed the extra space in '/translations'. and still is not working.
– Christopher A.
Nov 14 '18 at 19:52
server.listen(port, hostname, () => console.log(Server running at $hostname:$port); );
– Christopher A.
Nov 14 '18 at 19:52
I removed the extra space and I am gettingtranslationswhen queryinglocalhost:3000/translations
– Rastalamm
Nov 14 '18 at 19:57
What does this have to do with nodemon? Can your share the rest of the file/code for this? You also may have an extra space in '/ translations'.
– Rastalamm
Nov 14 '18 at 19:19
What does this have to do with nodemon? Can your share the rest of the file/code for this? You also may have an extra space in '/ translations'.
– Rastalamm
Nov 14 '18 at 19:19
Here is the remaining piece of code below. Nodemon allows us to automatically restart the server when ever we update our application and hit save. I have also removed the extra space in '/translations'. and still is not working.
– Christopher A.
Nov 14 '18 at 19:52
Here is the remaining piece of code below. Nodemon allows us to automatically restart the server when ever we update our application and hit save. I have also removed the extra space in '/translations'. and still is not working.
– Christopher A.
Nov 14 '18 at 19:52
server.listen(port, hostname, () => console.log(
Server running at $hostname:$port); );– Christopher A.
Nov 14 '18 at 19:52
server.listen(port, hostname, () => console.log(
Server running at $hostname:$port); );– Christopher A.
Nov 14 '18 at 19:52
I removed the extra space and I am getting
translations when querying localhost:3000/translations– Rastalamm
Nov 14 '18 at 19:57
I removed the extra space and I am getting
translations when querying localhost:3000/translations– Rastalamm
Nov 14 '18 at 19:57
add a comment |
1 Answer
1
active
oldest
votes
You have an extra space in your if statement when checking for the url path. The below should work.
if (url === '/translations')
res.end ('translations');
I just cleared the extra space in the if statement and is still not working
– Christopher A.
Nov 14 '18 at 20:05
if (url === '/translations') res.end ('translations');
– Christopher A.
Nov 14 '18 at 20:05
Not sure if this has anything to do with it but removeNodefromconst http = require('http');Aside from these two changes, I have no problems with getting'translations'or'Hi Chris, Welcome too Node!'to be in the response
– Rastalamm
Nov 15 '18 at 14:30
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53306864%2fjson-and-nodemon-functionality%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have an extra space in your if statement when checking for the url path. The below should work.
if (url === '/translations')
res.end ('translations');
I just cleared the extra space in the if statement and is still not working
– Christopher A.
Nov 14 '18 at 20:05
if (url === '/translations') res.end ('translations');
– Christopher A.
Nov 14 '18 at 20:05
Not sure if this has anything to do with it but removeNodefromconst http = require('http');Aside from these two changes, I have no problems with getting'translations'or'Hi Chris, Welcome too Node!'to be in the response
– Rastalamm
Nov 15 '18 at 14:30
add a comment |
You have an extra space in your if statement when checking for the url path. The below should work.
if (url === '/translations')
res.end ('translations');
I just cleared the extra space in the if statement and is still not working
– Christopher A.
Nov 14 '18 at 20:05
if (url === '/translations') res.end ('translations');
– Christopher A.
Nov 14 '18 at 20:05
Not sure if this has anything to do with it but removeNodefromconst http = require('http');Aside from these two changes, I have no problems with getting'translations'or'Hi Chris, Welcome too Node!'to be in the response
– Rastalamm
Nov 15 '18 at 14:30
add a comment |
You have an extra space in your if statement when checking for the url path. The below should work.
if (url === '/translations')
res.end ('translations');
You have an extra space in your if statement when checking for the url path. The below should work.
if (url === '/translations')
res.end ('translations');
answered Nov 14 '18 at 19:54
RastalammRastalamm
735822
735822
I just cleared the extra space in the if statement and is still not working
– Christopher A.
Nov 14 '18 at 20:05
if (url === '/translations') res.end ('translations');
– Christopher A.
Nov 14 '18 at 20:05
Not sure if this has anything to do with it but removeNodefromconst http = require('http');Aside from these two changes, I have no problems with getting'translations'or'Hi Chris, Welcome too Node!'to be in the response
– Rastalamm
Nov 15 '18 at 14:30
add a comment |
I just cleared the extra space in the if statement and is still not working
– Christopher A.
Nov 14 '18 at 20:05
if (url === '/translations') res.end ('translations');
– Christopher A.
Nov 14 '18 at 20:05
Not sure if this has anything to do with it but removeNodefromconst http = require('http');Aside from these two changes, I have no problems with getting'translations'or'Hi Chris, Welcome too Node!'to be in the response
– Rastalamm
Nov 15 '18 at 14:30
I just cleared the extra space in the if statement and is still not working
– Christopher A.
Nov 14 '18 at 20:05
I just cleared the extra space in the if statement and is still not working
– Christopher A.
Nov 14 '18 at 20:05
if (url === '/translations') res.end ('translations');
– Christopher A.
Nov 14 '18 at 20:05
if (url === '/translations') res.end ('translations');
– Christopher A.
Nov 14 '18 at 20:05
Not sure if this has anything to do with it but remove
Node from const http = require('http'); Aside from these two changes, I have no problems with getting 'translations' or 'Hi Chris, Welcome too Node!' to be in the response– Rastalamm
Nov 15 '18 at 14:30
Not sure if this has anything to do with it but remove
Node from const http = require('http'); Aside from these two changes, I have no problems with getting 'translations' or 'Hi Chris, Welcome too Node!' to be in the response– Rastalamm
Nov 15 '18 at 14:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53306864%2fjson-and-nodemon-functionality%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What does this have to do with nodemon? Can your share the rest of the file/code for this? You also may have an extra space in '/ translations'.
– Rastalamm
Nov 14 '18 at 19:19
Here is the remaining piece of code below. Nodemon allows us to automatically restart the server when ever we update our application and hit save. I have also removed the extra space in '/translations'. and still is not working.
– Christopher A.
Nov 14 '18 at 19:52
server.listen(port, hostname, () => console.log(
Server running at $hostname:$port); );– Christopher A.
Nov 14 '18 at 19:52
I removed the extra space and I am getting
translationswhen queryinglocalhost:3000/translations– Rastalamm
Nov 14 '18 at 19:57