Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
364 views
in Technique[技术] by (71.8m points)

typescript - Angular Backend HTTP Request

I want to send an HTTP POST request to my backend in Ruby on Rails, Unfortunately, the backend does not receive any request.

Heres my code:

const params = new HttpParams()
        .set('subject', this.dialogForm.controls['subject'].value)
        .set('start_date', moment(this.dialogForm.controls['startDatePicker'].value).format('YYYY-MM-DD HH:mm:ss').toString())
        .set('due_date', moment(this.dialogForm.controls['dueDatePicker'].value).format('YYYY-MM-DD HH:mm:ss').toString())
        .set('description', this.dialogForm.controls['description'].value);
      console.log(params);

      this.http.post(API_BASE_URL + 'angular_calendar/custom_meetings/create', ' ', {params})
        .pipe(
          catchError(this.handleError)
        );

Does anyone have an idea how to solve this

question from:https://stackoverflow.com/questions/65918887/angular-backend-http-request

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

http requests are only sent when the observable returned by post() is subscribed to.

this.http.post(API_BASE_URL + 'angular_calendar/custom_meetings/create', ' ', {params}).pipe(
    catchError(this.handleError)
).subscribe(result => {
    // do something with the result
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...