title: UnhandledPromiseRejectionWarning TypeError: Cannot read property 'property' of undefined
body: <p>I have the following code, it tries to read a txt, convert it to an array and then convert it to json, to save it in a db, but when calling the controller, I try to run the SaveReferences function, it sends me this error:
  UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'service' of undefined</p>
  <p>Also, send me this: Promise {
   TypeError: Cannot read property 'service' of undefined at GettingInfo.SaveReferences at GettingInfo.Readfile at ReferenceController.saved</p>
  <pre><code>  export interface Dataconf{
          service:number;
          name:string;
          ref:string
      }
      
      export class GettingInfo {
      
          constructor(private referenceService: ReferenceService) {
          }
      
          Readfile = () =&gt; {
      
              const file = path.resolve(__dirname, '../../../dist/entity/PRUEBA.txt')
              try {
                  const data = fs.readFileSync(file, 'utf-8');
                  const lines = data.split(&quot;\n&quot;)
                  let values = []
                  let bi = []
                  lines.forEach(line =&gt; {
                      line.trim()
                      values = line.split(&quot;\|&quot;, 6).map(a =&gt; a.trim());
                      bi.push(values)
                      console.log(bi)
       })
                  const convert = this.ConditionData(bi)
                  console.log(convert)
                  const save = this.SaveReferences(convert)
                  console.log(save)
      
              } catch (err) {
                  console.error(err), &quot;something has happened to the file&quot;;
              }
          }
      
          ConditionData(values): Array&lt;Dataconf&gt; {
              let resultado = [];
              values.forEach(arreglo =&gt; {
                  let ref = 'ref';
                  for (let i = 3; i &lt; arreglo.length; i++) {
                      if (arreglo[i].length &gt; 0) {
                          let obj = {
                              service: parseInt(arreglo[0]),
                              name: arreglo[1]
                          }
                          obj[ref] = arreglo[i];
                          resultado.push(obj);
                      }
                  }
              });
              console.log(&quot;resultado funcionConditionData&quot;, resultado)
              return resultado;
          }
  
  async SaveReferences(data: Array&lt;Dataconf&gt;) {
          console.log(&quot;array&quot;, data)
          let i
          let orderField = 0;
          let helper = data[i].service;
          for (i = 0; i &lt;= data.length; i++) {
              if (data[i].service != helper) {
                  helper = data[i].service;
                  orderField = 0
                  try {
                      let res = await this.referenceService.createReference({
                          service: data[i].service,
                          name: `ref${i}`,
                          label: data[i].ref,
                          longitud: 0,
                          order: orderField
                      });
                  } catch (e) {
                      console.error(e);
                  }
              }
          }
          return data;
      }
  </code></pre>