Create a vertical MEAN.js 0.4 crud module
In this video we’ll create a vertical module for MEAN.js 0.4 using the yeoman meanjs generator!
yo meanjs:vertical-module customer
Category: Mean Stack
Tags: MEAN
In this video we’ll create a vertical module for MEAN.js 0.4 using the yeoman meanjs generator!
yo meanjs:vertical-module customer
i used this with version 0.4.2 – https://github.com/meanjs/generator-meanjs
Getting Error : Can’t set headers after they are sent.
Hi,
Thank you very much for MEAN Videos, Very useful to understand Mean project..
I need some help one issues. I am facing one error “Can’t set headers after they are sent.”
This is my Code:
app.route(‘/’)
.get(categorys.list)
exports.list = function(req, res) {
Category.find().exec(function (err, categorys) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.render(‘index’, {
user: req.user || null,
request: req
});
res.json(categorys);
}
;
});
}
I want sent Categorys data as response but i am geeting mentioned error.
Note:- I dont want send categorys as user( user: req.user || null,) in response.
Thank you very much for your help.
Regards,
Krishna
Hey Krishna,
You actually have 3 responses in your code, so by the time the last one is reached (res.json(categorys), the response has already been sent.
npm install meanjs/generator-meanjs#0.4-dev
doesn’t seem to be working anymore. Is there another way to get the generator?
I know you recommend just cloning the git repo, and that’s fine and good for a start. But what happens when I want to create my own modules? I definitely would like to have a generator available for that
Hey Pedro –
If npm is giving you trouble – get it directly from the source https://github.com/meanjs/generator-meanjs/tree/0.4-dev
git clone -b branch repo
some how somewhere down the line I got it fixed not sure what the change was
thanks again! I am on MEAN Stack 9: GREAT JOB THANK YOU!
oh sorry taking up so much space I THINK the fault was that I did not have the yeoman mean js generator installed globally with sudo npm install -g meanjs etc.. hope this helps somebody
Thanks for pointing this out for anyone else who might be having the same issue 🙂
Do you know of a work around for this error? The videos have been very helpful learning the MEAN.js stack thank you!
/projects/mean# yo meanjs:crud-module customer
Error meanjs:crud-module customer
You don’t seem to have a generator with the name meanjs:crud-module installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 0 registered generators run yo with the `–help` option.
Is this still the appropriate method of getting the 0.4.0 sub-generator(s) installed prior to release?
npm install meanjs/generator-meanjs#0.4-dev
For the sub generators – Yes, however, it’s probably not the best way to create a new meanjs project. For a new 0.4.0 project, I’d suggest cloning directly from the source.
Hello Schisti, First let me thank you for your 30-day challenge. You are an exceptionally talented individual not just for your programming knowledge but also for your innate teaching ability. There is a certain generosity to your explanations. Simply put this kind of resource was not accessible to me for other languages which I passed by as a first time developer. I’m stoked
That said I think it would compliment the foundation of the 30-day challenge and this vertical module to show how you can begin to work with a layer of complexity between two (or more) modules.
In my project for example:
I wish to produce a /slug url request that brings up any given {{user}} and their {{customers}}
(just to use the 30-day example you’ve already built up.)
Thank you! I appreciate your kind feedback! 🙂
I have a list of ‘upcoming videos to make’ and I’ll add your idea to the list. Communicating between modules can get tricky, and I can show you some simple ways to get around it using Services and Directives.