0

我想通过 Api 将已删除对象的列表发送到后端,我该怎么做?

 public deleteOrders(orderr: Order): Observable<string> {
 return this.http.delete<string>(url, order); >>> Error 

error : Type 'Order' has no properties in common with type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }'
4

2 回答 2

1

你可以做这样的事情!

deleteOrders(orderr: Order): Observable<string> {

      let body = JSON.stringify(
          {
            "token": "....",
            "content": {
            "orderr": orderr
          }
        }
      );
      let headers = new Headers({ 'Content-Type': 'application/json' });
      let options = new RequestOptions({
        headers: headers,
        body : body
      });

      return this.http.delete(url, options);
    }
于 2019-10-14T09:24:16.000 回答
0

看看这是否适合你!

headers = new HttpHeaders({}).set('Content-Type', 'application/json').set('Accept', 'application/json').set('Access-Control-Allow-Origin', '*');
  httpOptions = {
    headers: this.headers
  };  

deleteDocument(_id: string): Observable<any> {
     return this.http.delete<Order>(url + `${_id}`, this.httpOptions);
   }

图 1 图 2

于 2019-10-14T11:37:24.077 回答