I have a function where I want to return an array. This function makes a service call to my backend so I want to return the array when I know my service call is complete.
getList(id: number): MyArray[] {
    let temp: MyArray[] = [];
    this.service.getById(id).subscribe(
      singleId => {
        temp = temp.concat(singleId);
      },
      () => {},
      () => {
        this.myArray= temp;
        return temp;
      }
    );
  }
But when I compile my code it still gives me the error
A function whose declared type is neither 'void' nor 'any' must return a value.
If I return temp outside of the subscribe function, it returns nothing since the service call is not actually complete
 
    