Friday, 21 April 2017

How can I add a user with KeystoneJS if I don't have any users?

Sorry if this is an incredibly basic question but I can not find any helpful information out there.

I used the yeoman keystone generator to create a keystone project but MongoDB wasn't working when I ran the generator so the user didn't get created. I can not find any information on how to add the user.

Here is what I tried:

I added this to the routes/views/index.js file so it would get executed when the page loads:

var user = new User({
    name: { first:'matt', last:'x' },
    email: 'me@m.com',
    password: 'password',
    isAdmin: true
});

user.save(function (err) {
    if (err) {
        // handle error
        return console.log(err);
    }

    // user has been saved
    console.log(user);
});

This added a user to the database, but I get this error when I try to login:

Sorry, an error occurred loading the page (500)

Must supply api_key

How do I resolve this?

Thanks for any help.



via insomnius1

No comments:

Post a Comment