I am working on a application and I am using MEAN stack as technology. In AngularJS, I am using ngResource to CRUD operations. Can any one suggest how to send username and password to server and get response back to check if the credentials are valid. I need help in ngResource and mongoose code. Thanks.
How to post some data and get results using MEAN stack and ngResource
73 Views Asked by Sumant At
1
There are 1 best solutions below
Related Questions in ANGULARJS
- How to automatically change path in angular when scrolling
- Error two clicks to be able to login Angular 16
- Passing an array of objects through the $http.post method in angular JS does not work
- Understanding how to apply Angular Signals from beginning on an existing service
- provider duplicate while compiling a Cordova application for the Android platform
- How can I use angularjs $parse service in Angular?
- Width of custom headers in ag-grid (angular) doesn't match with column's width
- Issues with Katex/ngx-markdown Rendering in Angular 16
- How to make Angular SSR wait for async operations to finish that are initiated in ngOnInit?
- I want to install @angular/google-maps npm Package in angular 16.2.12 but "npm install @angular/google-maps" this is not working/ tell me other query
- Angular 17 standalone application integrate CKEditor 5 -- Error: window is not defined
- Why is $scope >= 0 showing true in interpolation while empty in controller?
- The XMLHttpRequest compatibility library was not found
- Making Gantt Chart Column Labels More Readable
- Pass key-value pairs of object as individual arguments to component in Angular
Related Questions in MONGOOSE
- How do I link two models in mongoose?
- Unable to Post Form Data to MongoDB because of picturepath
- Getting a Large Error Output When Calling MongoDB/Mongoose Functions Without an Error Message
- How to enter data in mongodb array at specific position such that if there is only 2 data in array and I want to insert at 5, then rest data is null
- connect ECONNREFUSED 43.205.72.30:27017 while connecting to Atlas
- How can I update existing mongodb database with a new array in Node js
- How Do Schema migration in mongoose & mongodb?
- How to save multiple string inside an array column in MongoDB
- Mongoose - Delete document with all array values are greater than specific value
- MongoDB - $lookup not getting an appropriate result
- Why do these two functions not return the same result?
- the transactions are not rolling back in mongodb
- Can anyone help to solve this
- Operation `todos.insertOne()` buffering timed out after 10000ms --- MongoDB Express Error
- Argument of type '"save"' is not assignable to parameter of type 'RegExp | "createCollection"' error while using pre method before saving schema
Related Questions in MEAN-STACK
- HttpErrorResponse cannot access _listId from mongo db by using params ANGULAR
- Workflow for an Angular form that also includes a file upload - what to do in case of errors (MEAN stack)
- Page not displaying on Chrome MacOS
- How to open upi apps from a MEAN app running on ios device with this link "upi://pay?pa=${upiId}&pn=%20&tr=%20&am=${amount}&cu=INR" working on android
- in angular 16 project when we call REST Api from project it will shows error but when we direct call from POSTMAN or browser it will shows data
- Subscribe method not working in MEAN stack application
- The register page is not taking the data it is showing success as false
- Design question: should calculation done in frontend be stored in backend?
- How can I use hardware keys (Yubikey and Titan Key) with multiple applications?
- I am having trouble connecting to the Stripe checkout API in my MEAN stack project
- MEAN Stack CORS error even after using CORS middleware
- how to add findone for name validation in nodejs details from mongodb
- Problem with angular 16 post in mean-stack
- How to convert the following code into non callbacks?
- MEAN STACK ,"Error in Postman : Username or password is invalid! "
Related Questions in ANGULARJS-RESOURCE
- AngularJS trouble with $resource call
- how to emit an event in a callback using $resource in angularJS
- AngularJS resource: Send query parameter only if non-empty
- How to Post Json array of objects in AngularJS (using $resource save or via $http service) and How to consume it in Resteasy
- I'm having problems accessing a $resource variable in AngularJS
- Method Not Allowed when calling DELETE method; possible routing issue
- angular.js:14195 Error: [$resource:badmember] Dotted member path "@" is invalid
- AngularJS resource service
- AngularJS: Minimal example with $resource and timeout
- Use ngResource to query database in AngularJS
- Angular Resource: Error: $resource:badcfg
- Angularjs how to loads required js files home page index.html
- Custom method in an Angular service using $resource in Jhipster
- Cannot read property 'index' of undefined
- AngularJS ngResource $resource query() Returns Empty
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Check out the mean.js boilerplate: https://github.com/meanjs/mean
You'll see how they do it pretty quickly:
moduleName.client.controller.jswill make an http call, using the injected http. Here is an example of the call being made from/modules/users/client/controllers/authentication.client.controller.js(with some edits to the code to make it easier to see what you're looking for):Now, this call is posted to '/api/auth/signup'. The file that handles this route is located in
/modules/users/server/routes/auth.server.routes.js:As you can see, the route (the url) matches the one you called from the client controller. As that $http call from the controller was a
$http.post(), the route entry must match. You can see that it does above. The parameterusers.signuppassed above refers to a function in yet another file:/modules/users/server/controllers/users/users.authentication.server.controller.js. This is your main controller for the authentication part of theusersmodule. Now, within this file we can see thesignupfunction is exported:Now, a lot is going on here, but we can break it down.
The
reqvariable is the post request as passed by $http. Theresvariable is the response the client expects to receive back. Notice howvm.credentialswas passed in$http.post('/api/auth/signup/', vm.credentials)? This is bound toreq.bodyand may be accessed by your server controller from that.So in this example, the req.body is the required data to create a new user on the server. This is done using mongoose, which has a schema called User. Access this by declaring globals at the top of your controller:
You can see that a new user is instantiated above. It is saved via the mongoose call
.save().Lastly, your server functions should response to the client's request using the
resvariable passed to the function. See how once the user is created successfully, the function callsThis is
success()to the client, which accepts the response and binds it to a local variablevm.authentication.userHope this helps!