Personal Information Management

After making a request for stormpath user custom data, I used the following code:

res.render('home', {
title: 'home',
user: req.user.customData,


});

Instead of receiving a JSON object of custom data as expected, a URL ('') was returned. Although the page contains the desired custom data, it cannot be requested using an ajax request due to being a HTTPS page. What steps should I take next? Thank you in advance.

Answer №1

To utilize the automatic expansion capability of the library, simply implement it in this manner:

app.use(stormpath.init(app, {
  expandCustomData: true,
});

This will automatically expand the custom data resource for your convenience. By default, it typically appears as a basic link to the resource, as you may have already noticed.

Answer №2

My approach to requesting custom data involves utilizing the getCustomData() method within the route, storing the data in a variable, and then making a client-side GET request to retrieve this data. Here's an example of how it can be done:

Server Js

customData = new Array;


 router.get("/string", function(req, res) {
            req.user.getCustomData(function(err, data) {
                   customData = data.someKey;
                   })

       res.send(customData) /*Returns Empty Arrray*/

 })
router.get("/cdata", function(req, res) {

    res.send(customData) /*Sends Actual Custom Data*/
}) 

Client Js

var customData = new array

$(document).ready(function() {
        $.get("/string", function(string) {
           /*Tells server to get customData*/ 
        })


    $(document).click(function(){
        if(pleaseCount===0){
        $.get("/cdata", function(data) {

              for(i=0;i<data.length;i++){
              customData.unshift(data[i])
              pleaseCount=pleaseCount+1
        /*Custom data is now stored in client side array*/
        }
      })
   }


    })

This method has proven effective for me. It's worth noting that utilizing userName:req.user.userName in the render function allows for the retrieval of other user information like name and email, which can be displayed on a jade page using p #{userName}.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is this error: "Unknown authentication strategy 'loca'"?

Whenever I try to utilize passport.js, it keeps throwing the following error: Unknown authentication strategy "local"! config/configuration.js var passport = require('passport') , LocalStrategy = require('passport-local').Strategy; ...

Updating the options list of an Autocomplete component post-render: A step-by-step guide

I've encountered an issue with a function that retrieves a JSON array from a URL containing a list of options to be displayed in my Autocomplete component. function DisplayOptions() { async function GetOptions() { options_list = await fetc ...

Encountering sporadic EACCES issues while executing selenium tests in the AVA framework

Encountering errors on Windows 10 1809 while using Chrome for testing purposes. Error message 1 Frequency: Occurs approximately every 50th driver instantiation. [...]project\node_modules\selenium-webdriver\net\portprober.js:159 ...

Why does the implementation of my interface differ from what is specified in the TypeScript documentation?

Currently delving into the world of TypeScript documentation https://www.typescriptlang.org/docs/handbook/2/classes.html Specifically focusing on the section implements Clauses, an interesting revelation surfaces: A Word of Caution It’s worth noting t ...

Eslint in Gulp can't locate my .eslintrc configuration file

My gulp-eslint is unable to locate my .eslintrc file. I've set up a lint task as follows: gulp.task('lint', function () { gulp.src(['src/**/*.js', 'src/**/*.jsx']) .pipe(eslint()) .pipe(eslint.format()); }) The t ...

Is there a way to prevent Azure DevOps from automatically updating the node/npm version?

Just a couple of days ago, on December 1st, 2021, Azure DevOps surprised us by automatically updating the default version of node and npm, causing our build pipelines to break. before: 2021-11-30T15:30:01.113Z https://i.stack.imgur.com/PPtRq.png after: ...

Developing a system mode called "night mode"

I've decided to incorporate a dark mode feature into my Wordpress theme. Creating both dark and light modes was a breeze, but now I want to add a third mode that serves as the default for pages. This new mode will automatically switch between dark a ...

Passing properties from the parent component to the child component in Vue3JS using TypeScript

Today marks my inaugural experience with VueJS, as we delve into a class project utilizing TypeScript. The task at hand is to transfer the attributes of the tabsData variable from the parent component (the view) to the child (the view component). Allow me ...

Is it possible to utilize $.each() in combination with $.ajax() to query an API?

I am dealing with an array containing 2 values, and for each value, I need to make an AJAX query to an API to check the stock availability. If there is stock for both values, a certain message should be executed, otherwise, a different message. This check ...

Sort an array using another array as the reference in JavaScript

I have encountered similar questions before, but my current challenge involves partially sorting an array based on values from another array. This is what I aim to achieve: let array = [ { name: "Foo", values: [a, b, c, d] }, { name: " ...

Using the .get() method to retrieve Firebase documents results in an error message saying "'is not a function'"

I'm currently attempting to retrieve all the documents from a specific collection in Firebase using the following code snippet: const userCollectionRef = collection(db, currentUser?.uid) const snapshot = await userCollectionRef.get() for (const doc of ...

ReactJS encounters errors even when the backend is returning a 200 OK status code

My ReactJS frontend receives an error when sending a GET request, even though the django backend terminal shows [10/Mar/2018 23:31:08] "GET /post/ HTTP/1.1" 200 930. I am using redux sagas in my project. In src/index.js: (index.js code snippet here) In ...

Error: The use of "let" as a lexically bound identifier is not permitted

Currently working with vue.js and encountering the error message "Uncaught SyntaxError: let is disallowed as a lexically bound name". When trying to troubleshoot, I'm faced with a blank screen and this error appearing in the console. I've search ...

Form using Ajax technology, including two drop-down menus sourced externally

Is there a way to automatically populate a second drop-down list with all models once a selection is made in the first drop-down on a form? Below is the code snippet: <form> <div class="landing_quote_left"> ...

Utilizing Selenium JavaScript to insert a cookie into a request

Trying to add a cookie to the request in Selenium using JavaScript. I followed the documentation at this link, but my code snippet doesn't seem to pass any cookies to the PHP script below on the server. Here is the client-side JavaScript code: var w ...

Efficient Error Handling in Next.JS with Apollo GraphQL Client

Although the component successfully renders the error state, an uncaught exception is displayed in the console and a dialogue box appears in the browser. How can expected errors be handled to prevent this behavior? import { useMutation, gql } from "@a ...

Using the symbol for pi in a JavaScript program rather than its numerical value, while still performing calculations with the numerical value behind the scenes

I am working on a calculator project where I want the symbol for pi to be displayed instead of the numerical value. Here is the relevant function: function Pi(pi) { document.getElementById('resultArea').innerHTML += pi; eval(document.ge ...

Utilizing ProtractorJS to Extract Numbers from Text within an Element and Dynamically Adding it to an Xpath Expression

Situation My objective is to extract text from an element on a webpage, convert that extracted text into a number in string format, and then use it for an xpath query. The code snippet below illustrates this process: var bookingRefString = element(by.css ...

Loading data dynamically in a table by utilizing the react WayPoint library

I'm currently utilizing a combination of material UI table and react-table. When the number of rows in the table exceeds around 200, the performance dips. To address this issue, I am looking to display a fixed number of rows (let's say 20 rows) i ...

Incorporate data into the input value rather than the div using Ajax technology

This ajax function is working perfectly, but I would like to modify the location where the result should appear. <script type="text/javascript"> function submitForm1() { var form1 = document.myform1; var dataString1 = $(form1).serialize(); $.ajax ...