Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8749817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:45:29+00:00 2026-06-13T12:45:29+00:00

This is my model. UserApiSchema.statics.createApi = function(user,fn){ var instance = new UserApi(); instance.user =

  • 0

This is my model.

UserApiSchema.statics.createApi = function(user,fn){
  var instance = new UserApi();
  instance.user = user;
  instance.apiKey = "asdasdacasdasasd";
  console.log("username is " + user.username);
  instance.save(function(err){
    fn(err,instance);
  });
};

UserSchema.statics.newUser = function (email, password,username, fn) {
    var instance = new User();
    var apiInstance = new UserApi();
    instance.email = email;
    instance.password =password;
    instance.username = username;

    instance.save(function (err) {
        fn(err, instance);
    });
};

This is my controller-users.js:

app.post(
‘/signup/’,
function(req, res) {
{console.log(req.body.username);
User.newUser(

            req.body.email, req.body.password,req.body.username,
            function (err, user) {
                if ((user)&&(!err)) {
                    console.log(user.username)

                    UserApi.createApi(
                            user,function(err,userapi){
                                if((!err)){
                                    res.send("APi created")
                                }
                                else{
                                    if(err.errors.apiKey){
                                        res.send(err)
                                    }
                                }


                            });
                    req.session.regenerate(function(){
                        req.session.user = user._id;
                        res.send("Success here!"); 

                    });
                } else {
                    if (err.errors.email) {
                          res.send(err) 
                          console.log(req.body.password);
                          console.log(req.body.email);
                          console.log(req.body);
                        }                           
                   if (err.errors.username) {
                      res.send(err) 
                      console.log(req.body.password);
                      console.log(req.body.email);
                      console.log(req.body);
                    }   
                }
            });


    } 
});

The concept is once the user-name/password is accepted, an API key is stored along with the username. Though, the username payload is getting accepted, when I do the UserApiSchema call to generate the api, no such api is generated. No errors either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:45:30+00:00Added an answer on June 13, 2026 at 12:45 pm

    Might be real basic … but, did you create the objects needed?

    • UserApiSchema = {};
    • UserApiSchema.statics = {};
    • UserApiSchema.statics.createApi = function(user,fn){ …}

    If so … are they in a module?
    Did you export them from the module?

    • exports.userApiSchema = UserApiSchema;

    Did you import them in controller-users.js?

    • var userApiSchema = require(‘./UserApiSchema.js’);
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If i have this model: var myParentModel = Backbone.Model.extend({ defaults:{ parent1: null, parent2: null}
I have this model var Item = Backbone.Model.extend({ url: 'http://localhost/InterprisePOS/Product/loaditembycategory/Event Materials' }); var onSuccess
Let's consider this model class Session(models.Model): tutor = models.ForeignKey(User) start_time = models.DateTimeField() end_time =
I have a model that holds user address. This model has to have first_name
I have this model: class blog(models.Model): user = models.ForeignKey(User) mail = models.EmailField(max_length=60, null=False, blank=False)
@this.Model.ActiveApplicationId @this.Html.DropDownList(applications, new SelectList(this.Model.AllApplications, ApplicationId, Title, this.Model.ActiveApplicationId)) renders... 17 <select id=applications> <option value=16>app 16</option>
I have this model class Vacancy(models.Model): user = models.ForeignKey(User, null=True, blank=True, default = None)
Given this definition: class Foo(var x: String) {} object Helper { def model[T](get: ⇒
I originally created an editor template like this @model MyModel var items = //
(I am new to paperclip) I have this model hierarchy: base model: class QuestDescription

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.