Giter Club home page Giter Club logo

webdevbootcamp's Issues

Cannot read property 'substring' of undefined

Hello!

I'm trying to resolve a problem with "Cannot read property 'substring' of undefined". Unfortunately, I have tried several options, but none of them gives the expected result. I have both deleted the database collection and tried to replace it with the if condition ( index file),

<% if(blog.body && blog.body.length > 0) { %> 
   <p><%= blog.body.substring(0, 100)%></p>
<% } > %

but it does not work and by deleting a post, it actually adds one:
image

What are the possible solutions in this case?

https://goor.me/Ax6az
P.S. added a file of my code at bottom of the page

Thanks in advance,
maox27

RESTfulRouting.zip

Request doesn't work

im trying to use "request-promise now and im having a very hard time.
var express = require("express");
var app = express();
var rp = require("request-promise");
app.set("view engine", "ejs");

app.get("/", function(req, res){
res.render("search");
});

app.get("/results", function(req, res){
var query = req.query.search;
var options = {
method: "GET",
uri: "http://omdbapi.com/?s=" + query,

};

rp(options)
.then((body)=> {
	var data = JSON.parse(body)
    console.log(data);
	// Process html..

})
.catch((err)=> {
	console.log( "error",err)
    // Crawling failed...
});
     
app.listen(process.env.PORT, process.env.IP, function(){
console.log("Movie App has started!!!");

});

Click twice on sign up button for flash message to appear.

YelpCamp routes/index.js line 22 change needed from:
req.flash("error", err.message);
return res.render("register");
to:
return res.render("register", {"error": err.message});
or:
req.flash("error", err.message);
return res.redirect("register");

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.