title: Access automatically created id of database while Observable is being created?
body: <p>I have this method:</p>
  <pre><code>onFormSubmit(formData: Pick&lt;Habit, 'name' | 'repeatVal' | 'notification' | 'color' | 'question'&gt;): void {
  this.habitService
    // tslint:disable-next-line:max-line-length
    .createHabit(formData, this.authService.userId)
    .pipe(first())
    .subscribe((results) =&gt; console.log(results)
    });
  console.log(formData);
  
  // I would like to use the id from my Observable here in this method
  this.statusService.createStatuses(id); 
  
  this.updateService.callRefresh.next(true);
  this.customizeForm.reset();
  this.formDirective.resetForm();
  // here the function to refresh the data-table should be called
  this.updateService.callRefresh.next(false);
  /*this.refresh.emit(null);*/
    }
  </code></pre>
  <p>Unfortunately &quot;results&quot; gets logged as &quot;undefined&quot;.
  This is my service with the method that makes a post request and returns an Observable:</p>
  <pre><code>createHabit(
  formData: Partial&lt;Habit&gt;,
  userId: Pick&lt;User, 'id'&gt;
  ): Observable&lt;Habit&gt; {
      return this.http
        .post&lt;Habit&gt;(
          this.habitsUrl,
          { name: formData.name,
            repeatVal: formData.repeatVal,
            notification: formData.notification,
            color: formData.color,
            question: formData.question,
            id: userId },
          this.httpOptions
        )
        .pipe(
          catchError(this.errorHandlerService.handleError&lt;Habit&gt;('createHabit'))
        );
    }
  </code></pre>
  <p>My service makes a post request to my database and there an automatic- autoincremented id gets created.</p>
  <p><strong>How can I access the id within my &quot;onFormSubmit&quot;-Method in order to use it in my &quot;createStatuses&quot; function?</strong></p>
  <p>This is my async-post-request-function:</p>
  <pre><code>exports.postHabit = async (req, res, next) =&gt; {
  const errors = validationResult(req);
  
  if(!errors.isEmpty()) return;
  
  const name = req.body.name;
  const repeatVal = req.body.repeatVal;
  const notification = req.body.notification;
  const color = req.body.color;
  const question = req.body.question;
  const id = req.body.id;
  
  try {
      const habitDetails = {
          name: name,
          repeatVal: repeatVal,
          notification: notification,
          color: color,
          question: question,
          id: id,
      };
  
      const result = await Habit.save(habitDetails);
  
      res.status(201).json(result)
  } catch (err) {
      if(!err.statusCode){
          err.statusCode = 500;
      }
      next(err)
  }
  };
  </code></pre>