How to use the @angular/http.RequestMethod.Delete function in @angular/http

To help you get started, we’ve selected a few @angular/http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coursefiles / angular2-essential-training / app / mock-xhr-backend.ts View on Github external
} else {
            var id = parseInt(request.url.split('/')[1]);
            mediaItems = this._mediaItems.filter(mediaItem => mediaItem.id === id);
            responseOptions = new ResponseOptions({
              body: JSON.parse(JSON.stringify(mediaItems[0])),
              status: 200
            });
          }
          break;
        case RequestMethod.Post:
          var mediaItem = JSON.parse(request.text().toString());
          mediaItem.id = this._getNewId();
          this._mediaItems.push(mediaItem);
          responseOptions = new ResponseOptions({ status: 201 });
          break;
        case RequestMethod.Delete:
          var id = parseInt(request.url.split('/')[1]);
          this._deleteMediaItem(id);
          responseOptions = new ResponseOptions({ status: 200 });
      }

      var responseObject = new Response(responseOptions);
      responseObserver.next(responseObject);
      responseObserver.complete();
      return () => { };
    });
    return { response };
github ronzeidman / ng2-ui-auth / src / jwt-http.service.ts View on Github external
delete(url: string, options?: JwtRequestOptionsArgs): Observable {
        options = options || {};
        options.method = RequestMethod.Delete;
        return this.request(url, options);
    }
github cloudfoundry / stratos / src / frontend / app / store / reducers / api-request-reducer / request-helpers.ts View on Github external
return 'create';
    }
    if (method === 'put') {
      return 'update';
    }
    if (method === 'delete') {
      return 'delete';
    }
  } else if (typeof method === 'number') {
    if (method === RequestMethod.Post) {
      return 'create';
    }
    if (method === RequestMethod.Put) {
      return 'update';
    }
    if (method === RequestMethod.Delete) {
      return 'delete';
    }
  }
  return 'fetch';
}
github cloudfoundry / stratos / src / app / store / reducers / api-request-reducer / request-helpers.ts View on Github external
return 'create';
    }
    if (method === 'put') {
      return 'update';
    }
    if (method === 'delete') {
      return 'delete';
    }
  } else if (typeof method === 'number') {
    if (method === RequestMethod.Post) {
      return 'create';
    }
    if (method === RequestMethod.Put) {
      return 'update';
    }
    if (method === RequestMethod.Delete) {
      return 'delete';
    }
  }
  return 'fetch';
}
github dotCMS / core-web / projects / dot-rules / src / lib / services / Rule.ts View on Github external
deleteRule(ruleId: string): Observable<{ success: boolean } | CwError> {
    const siteId = this.loadRulesSiteId();
    return this.coreWebService
      .request({
        method: RequestMethod.Delete,
        url: `${this._apiRoot.baseUrl}api/v1/sites/${siteId}${this._rulesEndpointUrl}/${ruleId}`
      }).pipe(
      map(result => {
        return { success: true };
      }));
  }
github chaibio / chaipcr / ng2 / src / app / services / experiment / experiment.service.spec.ts View on Github external
backend.connections.subscribe((connection: MockConnection) => {
        expect(connection.request.method).toBe(RequestMethod.Delete)
        //expect(connection.request.url).toBe(`/experiments/${expId}`)
        connection.mockRespond(new Response(new ResponseOptions({
          status: 200,
          body: {
            status: true
          }
        })))
        backendSpy()
      })
github myopenresources / cc / src / app / shared / http / http.service.ts View on Github external
public delete(url: string, paramMap: any = null, success: Function=function(successful, data, res){}, error: Function=function(successful, msg, err){}): any {
        return this.request(url, new RequestOptions({
            method: RequestMethod.Delete,
            search: HttpService.buildURLSearchParams(paramMap).toString()
        }), success, error);
    }
github Teradata / covalent / src / platform / http-deprec / http-rest.service.spec.ts View on Github external
mockBackend.connections.subscribe((connection: MockConnection) => {
        expect(connection.request.url).toBe(
          'www.url.com/path/to/endpoint/id-of-something',
          'url with :id didnt match the expected url',
        );
        expect(connection.request.method).toBe(RequestMethod.Delete, 'request didnt have DELETE method');
        connection.mockRespond(
          new Response(
            new ResponseOptions({
              status: 200,
              body: JSON.stringify('success'),
            }),
          ),
        );
      });
      let success: boolean = false;
github outcobra / outstanding-cobra / frontend / src / app / core / http / http-interceptor.ts View on Github external
public delete(url: string, apiName?: string, params?: any): Observable {
        return this.request({
            method: RequestMethod.Delete,
            url: url,
            params: params,
            apiName: apiName
        });
    }
github Teradata / covalent / src / platform / http / http-rest.service.spec.ts View on Github external
mockBackend.connections.subscribe((connection: MockConnection) => {
        expect(connection.request.url)
        .toBe('www.url.com/path/to/endpoint/id-of-something',
              'url with :id didnt match the expected url');
        expect(connection.request.method).toBe(RequestMethod.Delete, 'request didnt have DELETE method');
        connection.mockRespond(new Response(new ResponseOptions({
            status: 200,
            body: JSON.stringify('success')},
        )));
      });
      let success: boolean = false;