Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RequestBuilderService

An Angular service to easily create RequestBuilder objects.

example
import { Injectable } from '@angular/core';
import { RequestBuilderService } from 'ng-request-builder';

@Injectable()
export class MyService {

  constructor(private requestBuilderService: RequestBuilderService) {
  }

  public doStuff(): Observable<Response> {
    return this.requestBuilderService
      .get('http://example.com')
      .header('Authorization', 'Bearer secret')
      .search('offset', 25)
      .search('limit', 50)
      .execute()
  }

}

Hierarchy

  • RequestBuilderService

Index

Constructors

constructor

Methods

delete

get

head

options

patch

  • patch(url: string, body?: any, contentType?: string): RequestBuilder
  • Returns a RequestBuilder configured to perform a PATCH request to the specified URL.

    example
    
    requestBuilderService.patch('http://example.com/path'); // without a body
    requestBuilderService.patch('http://example.com/path', { foo: 'bar' }); // with a body
    

    Parameters

    • url: string
    • Optional body: any
    • Optional contentType: string

    Returns RequestBuilder

post

  • Returns a RequestBuilder configured to perform a POST request to the specified URL.

    example
    
    requestBuilderService.post('http://example.com/path'); // without a body
    requestBuilderService.post('http://example.com/path', { foo: 'bar' }); // with a body
    

    Parameters

    • url: string
    • Optional body: any
    • Optional contentType: string

    Returns RequestBuilder

put

  • Returns a RequestBuilder configured to perform a PUT request to the specified URL.

    example
    
    requestBuilderService.put('http://example.com/path'); // without a body
    requestBuilderService.put('http://example.com/path', { foo: 'bar' }); // with a body
    

    Parameters

    • url: string
    • Optional body: any
    • Optional contentType: string

    Returns RequestBuilder

request

Generated using TypeDoc