Node.Js function runs twice when called once on promise return









up vote
1
down vote

favorite












I am attempting to create as many Google Slide slides as needed based on user input. In theory, my code should work if I can fix this one problem. The problem is, I can't. When I run my code, it stops because the createSlide() function runs twice on one call and creates two slides with the same Id. Poking around on the web, I've only found things about Node.Js input from a browser. First time through it runs ok, it does what it's supposed to, but when slide two (id: slide_1) is created it makes the slide, doubles the text such as:



Hi
bye


Would create



Hi
bye
Hi
bye


Then stop due to the fact that there cannot be two Ids that are the same. Here is my code (I've deleted the requests since the slide creation works fine):



function askYOrN(auth)

console.log("HELLO");

const r4 = readline.createInterface(
input: process.stdin,
output: process.stdout
);

r4.question("Do you want to add a slide [Y/N]? ", function(yesOrNo)
yesOrNoLog = yesOrNo;
r4.close();
fAskForNewCounter = fAskForNewCounter + 1;
askForNew(auth);
);


//ASKS IF ANOTHER SLIDE IS NEEDED
function askForNew(auth)

//DECLARATION FOR THE NUMBER COUNTER [ num ]
var num = 0;

function createSlide(auth)

//AUTHENTICATION
const slides = google.slides(version: 'v1', auth);

//CHANGES txtArray TO STRING
var txt = txtArray.join('');

//CHANGING VARS
var slideId = 'slide_' + num;
var pageId = slideId;

var textId = 'text_box_' + num;
var elementId = textId;

var iIndex = num;

//SLIDE NUMBER
var sNum = num + 1;


console.log(pageId);

//ALL REQUESTS GO IN requests
var requests = [
];

//BATCH UPDATE
return slides.presentations.batchUpdate(
presentationId,
resource:
requests,
,
, (err, res) =>
if (err)
error(err);
else
console.log("Slide #" + sNum + " has been created");

//INCREASES COUNTER BY 1
num = num + 1;

//ASKS IF A NEW SLIDE WANTS TO BE CREATED
var delay = 30;
var lastClick = 0;

if (lastClick >= (Date.now() - delay))
return;
lastClick = Date.now();

yesOrNoLog = "";
askYOrNo(auth);

);



Thanks in advance for your help!



EDIT

I have done some more work and have found that in my code r5.on is run twice. I tried deleting the array.push("n"). but this does not fix the problem. The array outputs as



[hi, bye, hi, bye]


This is my new code once again I have deleted the requests:



//ASKS IF YOU WANT A NEW SLIDE
function askYOrN(auth)

console.log("askYOrN");

const r4 = readline.createInterface(
input: process.stdin,
output: process.stdout,
terminal: false
);

r4.question("Do you want to add a slide [Y/N]? ", function(yesOrNo)
console.log("aksYOrN question");
yesOrNoLog = yesOrNo;
r4.close();
yOrNCheckCounter = yOrNCheckCounter + 1;
askYOrNCheck(auth);
);


//ASKS IF ANOTHER SLIDE IS NEEDED
function askYOrNCheck(auth)

//DECLARATION FOR THE NUMBER COUNTER [ num ]
var num = 0;

function createSlide(auth)

//AUTHENTICATION
const slides = google.slides(version: 'v1', auth);

//CHANGES txtArray TO STRING
var text = txtArray.join('n');

//CHANGING VARS
var slideId = 'slide_' + num;
var pageId = slideId;

var textId = 'text_box_' + num;
var elementId = textId;

var iIndex = num;

//SLIDE NUMBER
var sNum = num + 1;

console.log(pageId);

//ALL REQUESTS GO IN [ requests ]
var requests = ;

//BATCH UPDATE
return slides.presentations.batchUpdate(
presentationId,
resource:
requests,
,
, (err, res) =>
if (err) return error(err);
console.log("Slide #" + sNum + " has been created");

//INCREASES COUNTER BY 1
num = num + 1;

//ASKS IF A NEW SLIDE WANTS TO BE CREATED
askYOrN(auth);
);



Note:
I renamed askForNew() to askYOrNoCheck().



Once again thanks for your help.










share|improve this question























  • I highly recommend checking out Inquirer
    – FrankerZ
    Nov 13 at 0:57










  • First, I would suggest getting rid of your global variables. Without looking much at the code, it could either cause your current problem or future problems. Instead, pass the necessary variables around (e.g. checkAnswer(providedAnswer) /* ... */ ). Second, make sure to separate your functions into meaningful units. For example, askYOrNCheck() performs 2 actions: checking the user's answer and prompting for the slide text. This will help you think about what you're doing more clearly. Third, consider revisiting your names (e.g. askYOrNCheck should be checkAnswer).
    – c1moore
    Nov 13 at 1:21











  • The last tip makes the intent of the function more clear. The first few times I read it, I assumed you were going to prompt for the user's answer. While these don't solve your problem, addressing them will make it easier for others to help you and may help you figure out what is happening yourself because your program will be more semantically meaningful and better defined.
    – c1moore
    Nov 13 at 1:23










  • Actually, instead of checkAnswer, you may want to use something like shouldAddSlide(providedAnswer) that returns true if the user entered yes or y, false if the user entered no or n, or throws an error if the user entered anything else.
    – c1moore
    Nov 13 at 1:28










  • @c1moore Thank you for your suggestions I will definitely go through my code. However I have found the issue, I forgot to close the readline so it was pushing 2 answers instead of one.
    – Arkin Solomon
    Nov 13 at 1:41














up vote
1
down vote

favorite












I am attempting to create as many Google Slide slides as needed based on user input. In theory, my code should work if I can fix this one problem. The problem is, I can't. When I run my code, it stops because the createSlide() function runs twice on one call and creates two slides with the same Id. Poking around on the web, I've only found things about Node.Js input from a browser. First time through it runs ok, it does what it's supposed to, but when slide two (id: slide_1) is created it makes the slide, doubles the text such as:



Hi
bye


Would create



Hi
bye
Hi
bye


Then stop due to the fact that there cannot be two Ids that are the same. Here is my code (I've deleted the requests since the slide creation works fine):



function askYOrN(auth)

console.log("HELLO");

const r4 = readline.createInterface(
input: process.stdin,
output: process.stdout
);

r4.question("Do you want to add a slide [Y/N]? ", function(yesOrNo)
yesOrNoLog = yesOrNo;
r4.close();
fAskForNewCounter = fAskForNewCounter + 1;
askForNew(auth);
);


//ASKS IF ANOTHER SLIDE IS NEEDED
function askForNew(auth)

//DECLARATION FOR THE NUMBER COUNTER [ num ]
var num = 0;

function createSlide(auth)

//AUTHENTICATION
const slides = google.slides(version: 'v1', auth);

//CHANGES txtArray TO STRING
var txt = txtArray.join('');

//CHANGING VARS
var slideId = 'slide_' + num;
var pageId = slideId;

var textId = 'text_box_' + num;
var elementId = textId;

var iIndex = num;

//SLIDE NUMBER
var sNum = num + 1;


console.log(pageId);

//ALL REQUESTS GO IN requests
var requests = [
];

//BATCH UPDATE
return slides.presentations.batchUpdate(
presentationId,
resource:
requests,
,
, (err, res) =>
if (err)
error(err);
else
console.log("Slide #" + sNum + " has been created");

//INCREASES COUNTER BY 1
num = num + 1;

//ASKS IF A NEW SLIDE WANTS TO BE CREATED
var delay = 30;
var lastClick = 0;

if (lastClick >= (Date.now() - delay))
return;
lastClick = Date.now();

yesOrNoLog = "";
askYOrNo(auth);

);



Thanks in advance for your help!



EDIT

I have done some more work and have found that in my code r5.on is run twice. I tried deleting the array.push("n"). but this does not fix the problem. The array outputs as



[hi, bye, hi, bye]


This is my new code once again I have deleted the requests:



//ASKS IF YOU WANT A NEW SLIDE
function askYOrN(auth)

console.log("askYOrN");

const r4 = readline.createInterface(
input: process.stdin,
output: process.stdout,
terminal: false
);

r4.question("Do you want to add a slide [Y/N]? ", function(yesOrNo)
console.log("aksYOrN question");
yesOrNoLog = yesOrNo;
r4.close();
yOrNCheckCounter = yOrNCheckCounter + 1;
askYOrNCheck(auth);
);


//ASKS IF ANOTHER SLIDE IS NEEDED
function askYOrNCheck(auth)

//DECLARATION FOR THE NUMBER COUNTER [ num ]
var num = 0;

function createSlide(auth)

//AUTHENTICATION
const slides = google.slides(version: 'v1', auth);

//CHANGES txtArray TO STRING
var text = txtArray.join('n');

//CHANGING VARS
var slideId = 'slide_' + num;
var pageId = slideId;

var textId = 'text_box_' + num;
var elementId = textId;

var iIndex = num;

//SLIDE NUMBER
var sNum = num + 1;

console.log(pageId);

//ALL REQUESTS GO IN [ requests ]
var requests = ;

//BATCH UPDATE
return slides.presentations.batchUpdate(
presentationId,
resource:
requests,
,
, (err, res) =>
if (err) return error(err);
console.log("Slide #" + sNum + " has been created");

//INCREASES COUNTER BY 1
num = num + 1;

//ASKS IF A NEW SLIDE WANTS TO BE CREATED
askYOrN(auth);
);



Note:
I renamed askForNew() to askYOrNoCheck().



Once again thanks for your help.










share|improve this question























  • I highly recommend checking out Inquirer
    – FrankerZ
    Nov 13 at 0:57










  • First, I would suggest getting rid of your global variables. Without looking much at the code, it could either cause your current problem or future problems. Instead, pass the necessary variables around (e.g. checkAnswer(providedAnswer) /* ... */ ). Second, make sure to separate your functions into meaningful units. For example, askYOrNCheck() performs 2 actions: checking the user's answer and prompting for the slide text. This will help you think about what you're doing more clearly. Third, consider revisiting your names (e.g. askYOrNCheck should be checkAnswer).
    – c1moore
    Nov 13 at 1:21











  • The last tip makes the intent of the function more clear. The first few times I read it, I assumed you were going to prompt for the user's answer. While these don't solve your problem, addressing them will make it easier for others to help you and may help you figure out what is happening yourself because your program will be more semantically meaningful and better defined.
    – c1moore
    Nov 13 at 1:23










  • Actually, instead of checkAnswer, you may want to use something like shouldAddSlide(providedAnswer) that returns true if the user entered yes or y, false if the user entered no or n, or throws an error if the user entered anything else.
    – c1moore
    Nov 13 at 1:28










  • @c1moore Thank you for your suggestions I will definitely go through my code. However I have found the issue, I forgot to close the readline so it was pushing 2 answers instead of one.
    – Arkin Solomon
    Nov 13 at 1:41












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am attempting to create as many Google Slide slides as needed based on user input. In theory, my code should work if I can fix this one problem. The problem is, I can't. When I run my code, it stops because the createSlide() function runs twice on one call and creates two slides with the same Id. Poking around on the web, I've only found things about Node.Js input from a browser. First time through it runs ok, it does what it's supposed to, but when slide two (id: slide_1) is created it makes the slide, doubles the text such as:



Hi
bye


Would create



Hi
bye
Hi
bye


Then stop due to the fact that there cannot be two Ids that are the same. Here is my code (I've deleted the requests since the slide creation works fine):



function askYOrN(auth)

console.log("HELLO");

const r4 = readline.createInterface(
input: process.stdin,
output: process.stdout
);

r4.question("Do you want to add a slide [Y/N]? ", function(yesOrNo)
yesOrNoLog = yesOrNo;
r4.close();
fAskForNewCounter = fAskForNewCounter + 1;
askForNew(auth);
);


//ASKS IF ANOTHER SLIDE IS NEEDED
function askForNew(auth)

//DECLARATION FOR THE NUMBER COUNTER [ num ]
var num = 0;

function createSlide(auth)

//AUTHENTICATION
const slides = google.slides(version: 'v1', auth);

//CHANGES txtArray TO STRING
var txt = txtArray.join('');

//CHANGING VARS
var slideId = 'slide_' + num;
var pageId = slideId;

var textId = 'text_box_' + num;
var elementId = textId;

var iIndex = num;

//SLIDE NUMBER
var sNum = num + 1;


console.log(pageId);

//ALL REQUESTS GO IN requests
var requests = [
];

//BATCH UPDATE
return slides.presentations.batchUpdate(
presentationId,
resource:
requests,
,
, (err, res) =>
if (err)
error(err);
else
console.log("Slide #" + sNum + " has been created");

//INCREASES COUNTER BY 1
num = num + 1;

//ASKS IF A NEW SLIDE WANTS TO BE CREATED
var delay = 30;
var lastClick = 0;

if (lastClick >= (Date.now() - delay))
return;
lastClick = Date.now();

yesOrNoLog = "";
askYOrNo(auth);

);



Thanks in advance for your help!



EDIT

I have done some more work and have found that in my code r5.on is run twice. I tried deleting the array.push("n"). but this does not fix the problem. The array outputs as



[hi, bye, hi, bye]


This is my new code once again I have deleted the requests:



//ASKS IF YOU WANT A NEW SLIDE
function askYOrN(auth)

console.log("askYOrN");

const r4 = readline.createInterface(
input: process.stdin,
output: process.stdout,
terminal: false
);

r4.question("Do you want to add a slide [Y/N]? ", function(yesOrNo)
console.log("aksYOrN question");
yesOrNoLog = yesOrNo;
r4.close();
yOrNCheckCounter = yOrNCheckCounter + 1;
askYOrNCheck(auth);
);


//ASKS IF ANOTHER SLIDE IS NEEDED
function askYOrNCheck(auth)

//DECLARATION FOR THE NUMBER COUNTER [ num ]
var num = 0;

function createSlide(auth)

//AUTHENTICATION
const slides = google.slides(version: 'v1', auth);

//CHANGES txtArray TO STRING
var text = txtArray.join('n');

//CHANGING VARS
var slideId = 'slide_' + num;
var pageId = slideId;

var textId = 'text_box_' + num;
var elementId = textId;

var iIndex = num;

//SLIDE NUMBER
var sNum = num + 1;

console.log(pageId);

//ALL REQUESTS GO IN [ requests ]
var requests = ;

//BATCH UPDATE
return slides.presentations.batchUpdate(
presentationId,
resource:
requests,
,
, (err, res) =>
if (err) return error(err);
console.log("Slide #" + sNum + " has been created");

//INCREASES COUNTER BY 1
num = num + 1;

//ASKS IF A NEW SLIDE WANTS TO BE CREATED
askYOrN(auth);
);



Note:
I renamed askForNew() to askYOrNoCheck().



Once again thanks for your help.










share|improve this question















I am attempting to create as many Google Slide slides as needed based on user input. In theory, my code should work if I can fix this one problem. The problem is, I can't. When I run my code, it stops because the createSlide() function runs twice on one call and creates two slides with the same Id. Poking around on the web, I've only found things about Node.Js input from a browser. First time through it runs ok, it does what it's supposed to, but when slide two (id: slide_1) is created it makes the slide, doubles the text such as:



Hi
bye


Would create



Hi
bye
Hi
bye


Then stop due to the fact that there cannot be two Ids that are the same. Here is my code (I've deleted the requests since the slide creation works fine):



function askYOrN(auth)

console.log("HELLO");

const r4 = readline.createInterface(
input: process.stdin,
output: process.stdout
);

r4.question("Do you want to add a slide [Y/N]? ", function(yesOrNo)
yesOrNoLog = yesOrNo;
r4.close();
fAskForNewCounter = fAskForNewCounter + 1;
askForNew(auth);
);


//ASKS IF ANOTHER SLIDE IS NEEDED
function askForNew(auth)

//DECLARATION FOR THE NUMBER COUNTER [ num ]
var num = 0;

function createSlide(auth)

//AUTHENTICATION
const slides = google.slides(version: 'v1', auth);

//CHANGES txtArray TO STRING
var txt = txtArray.join('');

//CHANGING VARS
var slideId = 'slide_' + num;
var pageId = slideId;

var textId = 'text_box_' + num;
var elementId = textId;

var iIndex = num;

//SLIDE NUMBER
var sNum = num + 1;


console.log(pageId);

//ALL REQUESTS GO IN requests
var requests = [
];

//BATCH UPDATE
return slides.presentations.batchUpdate(
presentationId,
resource:
requests,
,
, (err, res) =>
if (err)
error(err);
else
console.log("Slide #" + sNum + " has been created");

//INCREASES COUNTER BY 1
num = num + 1;

//ASKS IF A NEW SLIDE WANTS TO BE CREATED
var delay = 30;
var lastClick = 0;

if (lastClick >= (Date.now() - delay))
return;
lastClick = Date.now();

yesOrNoLog = "";
askYOrNo(auth);

);



Thanks in advance for your help!



EDIT

I have done some more work and have found that in my code r5.on is run twice. I tried deleting the array.push("n"). but this does not fix the problem. The array outputs as



[hi, bye, hi, bye]


This is my new code once again I have deleted the requests:



//ASKS IF YOU WANT A NEW SLIDE
function askYOrN(auth)

console.log("askYOrN");

const r4 = readline.createInterface(
input: process.stdin,
output: process.stdout,
terminal: false
);

r4.question("Do you want to add a slide [Y/N]? ", function(yesOrNo)
console.log("aksYOrN question");
yesOrNoLog = yesOrNo;
r4.close();
yOrNCheckCounter = yOrNCheckCounter + 1;
askYOrNCheck(auth);
);


//ASKS IF ANOTHER SLIDE IS NEEDED
function askYOrNCheck(auth)

//DECLARATION FOR THE NUMBER COUNTER [ num ]
var num = 0;

function createSlide(auth)

//AUTHENTICATION
const slides = google.slides(version: 'v1', auth);

//CHANGES txtArray TO STRING
var text = txtArray.join('n');

//CHANGING VARS
var slideId = 'slide_' + num;
var pageId = slideId;

var textId = 'text_box_' + num;
var elementId = textId;

var iIndex = num;

//SLIDE NUMBER
var sNum = num + 1;

console.log(pageId);

//ALL REQUESTS GO IN [ requests ]
var requests = ;

//BATCH UPDATE
return slides.presentations.batchUpdate(
presentationId,
resource:
requests,
,
, (err, res) =>
if (err) return error(err);
console.log("Slide #" + sNum + " has been created");

//INCREASES COUNTER BY 1
num = num + 1;

//ASKS IF A NEW SLIDE WANTS TO BE CREATED
askYOrN(auth);
);



Note:
I renamed askForNew() to askYOrNoCheck().



Once again thanks for your help.







javascript node.js google-slides-api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 0:50

























asked Nov 9 at 6:41









Arkin Solomon

697




697











  • I highly recommend checking out Inquirer
    – FrankerZ
    Nov 13 at 0:57










  • First, I would suggest getting rid of your global variables. Without looking much at the code, it could either cause your current problem or future problems. Instead, pass the necessary variables around (e.g. checkAnswer(providedAnswer) /* ... */ ). Second, make sure to separate your functions into meaningful units. For example, askYOrNCheck() performs 2 actions: checking the user's answer and prompting for the slide text. This will help you think about what you're doing more clearly. Third, consider revisiting your names (e.g. askYOrNCheck should be checkAnswer).
    – c1moore
    Nov 13 at 1:21











  • The last tip makes the intent of the function more clear. The first few times I read it, I assumed you were going to prompt for the user's answer. While these don't solve your problem, addressing them will make it easier for others to help you and may help you figure out what is happening yourself because your program will be more semantically meaningful and better defined.
    – c1moore
    Nov 13 at 1:23










  • Actually, instead of checkAnswer, you may want to use something like shouldAddSlide(providedAnswer) that returns true if the user entered yes or y, false if the user entered no or n, or throws an error if the user entered anything else.
    – c1moore
    Nov 13 at 1:28










  • @c1moore Thank you for your suggestions I will definitely go through my code. However I have found the issue, I forgot to close the readline so it was pushing 2 answers instead of one.
    – Arkin Solomon
    Nov 13 at 1:41
















  • I highly recommend checking out Inquirer
    – FrankerZ
    Nov 13 at 0:57










  • First, I would suggest getting rid of your global variables. Without looking much at the code, it could either cause your current problem or future problems. Instead, pass the necessary variables around (e.g. checkAnswer(providedAnswer) /* ... */ ). Second, make sure to separate your functions into meaningful units. For example, askYOrNCheck() performs 2 actions: checking the user's answer and prompting for the slide text. This will help you think about what you're doing more clearly. Third, consider revisiting your names (e.g. askYOrNCheck should be checkAnswer).
    – c1moore
    Nov 13 at 1:21











  • The last tip makes the intent of the function more clear. The first few times I read it, I assumed you were going to prompt for the user's answer. While these don't solve your problem, addressing them will make it easier for others to help you and may help you figure out what is happening yourself because your program will be more semantically meaningful and better defined.
    – c1moore
    Nov 13 at 1:23










  • Actually, instead of checkAnswer, you may want to use something like shouldAddSlide(providedAnswer) that returns true if the user entered yes or y, false if the user entered no or n, or throws an error if the user entered anything else.
    – c1moore
    Nov 13 at 1:28










  • @c1moore Thank you for your suggestions I will definitely go through my code. However I have found the issue, I forgot to close the readline so it was pushing 2 answers instead of one.
    – Arkin Solomon
    Nov 13 at 1:41















I highly recommend checking out Inquirer
– FrankerZ
Nov 13 at 0:57




I highly recommend checking out Inquirer
– FrankerZ
Nov 13 at 0:57












First, I would suggest getting rid of your global variables. Without looking much at the code, it could either cause your current problem or future problems. Instead, pass the necessary variables around (e.g. checkAnswer(providedAnswer) /* ... */ ). Second, make sure to separate your functions into meaningful units. For example, askYOrNCheck() performs 2 actions: checking the user's answer and prompting for the slide text. This will help you think about what you're doing more clearly. Third, consider revisiting your names (e.g. askYOrNCheck should be checkAnswer).
– c1moore
Nov 13 at 1:21





First, I would suggest getting rid of your global variables. Without looking much at the code, it could either cause your current problem or future problems. Instead, pass the necessary variables around (e.g. checkAnswer(providedAnswer) /* ... */ ). Second, make sure to separate your functions into meaningful units. For example, askYOrNCheck() performs 2 actions: checking the user's answer and prompting for the slide text. This will help you think about what you're doing more clearly. Third, consider revisiting your names (e.g. askYOrNCheck should be checkAnswer).
– c1moore
Nov 13 at 1:21













The last tip makes the intent of the function more clear. The first few times I read it, I assumed you were going to prompt for the user's answer. While these don't solve your problem, addressing them will make it easier for others to help you and may help you figure out what is happening yourself because your program will be more semantically meaningful and better defined.
– c1moore
Nov 13 at 1:23




The last tip makes the intent of the function more clear. The first few times I read it, I assumed you were going to prompt for the user's answer. While these don't solve your problem, addressing them will make it easier for others to help you and may help you figure out what is happening yourself because your program will be more semantically meaningful and better defined.
– c1moore
Nov 13 at 1:23












Actually, instead of checkAnswer, you may want to use something like shouldAddSlide(providedAnswer) that returns true if the user entered yes or y, false if the user entered no or n, or throws an error if the user entered anything else.
– c1moore
Nov 13 at 1:28




Actually, instead of checkAnswer, you may want to use something like shouldAddSlide(providedAnswer) that returns true if the user entered yes or y, false if the user entered no or n, or throws an error if the user entered anything else.
– c1moore
Nov 13 at 1:28












@c1moore Thank you for your suggestions I will definitely go through my code. However I have found the issue, I forgot to close the readline so it was pushing 2 answers instead of one.
– Arkin Solomon
Nov 13 at 1:41




@c1moore Thank you for your suggestions I will definitely go through my code. However I have found the issue, I forgot to close the readline so it was pushing 2 answers instead of one.
– Arkin Solomon
Nov 13 at 1:41












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










Needed to add r5.close(). It took multiple inputs from one input.






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220975%2fnode-js-function-runs-twice-when-called-once-on-promise-return%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    Needed to add r5.close(). It took multiple inputs from one input.






    share|improve this answer
























      up vote
      0
      down vote



      accepted










      Needed to add r5.close(). It took multiple inputs from one input.






      share|improve this answer






















        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        Needed to add r5.close(). It took multiple inputs from one input.






        share|improve this answer












        Needed to add r5.close(). It took multiple inputs from one input.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 at 1:41









        Arkin Solomon

        697




        697



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220975%2fnode-js-function-runs-twice-when-called-once-on-promise-return%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

            Edmonton

            Crossroads (UK TV series)