带有手机号码的POST请求不起作用-消息:“手机号码字段为必填。↵”

时间:2019-10-02 09:01:00

标签: javascript angular typescript httpclient angular8

我从服务器{status: false, message: "The Mobile Number field is required.↵"}

获得响应
 submitForm() {
    this.createItem(this.data).subscribe((response) => {
        console.log(response)
        console.log(this.data)
    });
 }

此函数调用一个发送手机号码的函数

  createItem(data): Observable<MobileNo> {
    console.log(`data = ` ,JSON.stringify(data))
    return this.httpClient
      .post<MobileNo>(this.base_path, JSON.stringify(data), this.httpOptions)
      .pipe(
        retry(2),
        catchError(this.handleError),
      )
  }

发布数据的功能

 export class MobileNo {
    ext : string;
    mobile_no :string;
 }

MobileNo Class

<div class="container">
    <h3>Edit Student Data</h3>
    <div class="form-group">
        <label for="name">mobile</label>
        <input type="number" class="form-control" #todo id="name" [(ngModel)]="data.mobile_no" placeholder="Enter No">
    </div>
    <div class="form-group">
        <label for="age">ext</label>
        <input type="number" class="form-control" id="age" [(ngModel)]="data.ext" placeholder="Enter 91">
    </div>

    <button type="submit" class="btn btn-success" (click)="submitForm()">Update</button>
    <button type="submit" class="btn btn-warning ml-1" [routerLink]="[ '/welcome']">Cancel</button>
</div>

表格提交编号

我在这里做错了,我不知道

0 个答案:

没有答案