adamgibbons / ics

iCalendar (ics) file generator for node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Return Value Out of Scope All of a Sudden?

VikR1000 opened this issue · comments

This code, provided in the docs, has worked fine for years:

ics.createEvent(event, (error, value) => {
  if (error) {
    console.log(error)
    return
  }

  return value;
  

Then all of a sudden today I was getting errors on the line return value;, that value was null. I figured it was an out-of-scope error. Updating it to this fixed it:

    let icsString = ''
    ics.createEvent(iCalEvent, (error, value) => {
        icsString = value;
        if (error) {
            console.log('ics error: ', error);
            return
        }
    })
    return icsString;

But... it worked for years. Why did it need an update today?