javascript - Nodejs TypeError: undefined is not a function -


i'm following treehouse nodejs tutorial , ran error. server response in router unable find view method in renderer.

router.js:10 response.view("header", {}, response);        ^ typeerror: undefined not function 

renderer.js

var fs = require("fs");  function view(templatename, values, response) {   //read template files   var filecontents = fs.readfilesync('./views/' + templatename +   '.html');   //insert values in content   //write out contents response   response.write(filecontents); }  module.exports.view = view; 

router.js

var profile = require("./profile.js"); var renderer = require("./renderer.js");  //handle http route / , post / i.e. home function home(request, response) {   //if url == "/" &&   if(request.url === "/") {   //show search   response.writehead(200, {'content-type': 'text/plain'});   response.view("header", {}, response);   response.write("search\n");   response.end("footer\n");  } } 

you not using renderer anywhere in router.js.

i believe meant call renderer.view instead of response.view.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -