title: How to pass a value inside an observable with getObject function (aws / S3) in Angular
body: <p>I try to learn observable programming with Angular (4.4.6):</p>
  
  <p>Like to do: get json file from AWS / S3 Storage, save content (string), return the content in the observable.</p>
  
  <p>employee.service.ts:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { Observable } from 'rxjs/Observable';
  import { BehaviorSubject } from 'rxjs/BehaviorSubject';
  import 'rxjs/add/observable/of';
  import * as AWS from 'aws-sdk/global';
  import * as S3 from 'aws-sdk/clients/s3';
  
  ...  
  
  getNotice (userid): Observable&lt;String&gt; {
  
      const params = {
         Bucket: 'data.feedback.domain.de',
         Key: 'employees/' + userid + '/notice/notice.json'
      };
  
      var objectData = '';
  
      this.bucket.getObject(params, function (err, data) {
        if (err) {
          console.log('There was an error getting your files: ' + err);
          return;
        }
        console.log('Successfully get file: notice.json:', data.Body.toString());
        objectData = data.Body.toString();
      });
      console.log('objectData:', objectData);
      return Observable.of(objectData);
  
  }
  ...
  </code></pre>
  
  <p>In the getObject function I receive the file notice.json and in the console I see the string saved in notice.json.</p>
  
  <p>But saving the data with <em>objectData = data.Body.toString()</em> doesn't work.</p>
  
  <p>Any hint, what I'm doing wrong?</p>