Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
How to export promise variables?

what I am trying to do is to export set_cookies and csrf_token from the GetSolManCredentials.js to Create.js. I have tried to export the values as variables: module.exports.csrf_token =csrf_token; or even as function by creating a function module.exports = function (){}. However, no luck.

GetSolManCredentials.js

return new Promise(function(resolve, reject) {

   request.onload = () => {
      console.log(request.status);
      if (request.status == 200) {
        var cookies = request.getResponseHeader("set-cookie");
        var set_cookies = cookies[2];
        console.log("Cookies: " + set_cookies);
        var csrf_token = request.getResponseHeader("x-csrf-token");
        console.log("csrf token: " + csrf_token);
        resolve(set_cookies,csrf_token);
      } else {
        reject ("Something went wrong while getting cookies");
      }
    }
  });

Create.js

var returnToken = require("./GetSolManCredentials.js");

Appreciate your help.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!