File

projects/common/recaptcha/src/recaptcha-data.service.ts

Index

Methods

Constructor

constructor(httpClient: HttpClient)
Parameters :
Name Type Optional
httpClient HttpClient No

Methods

Public verifyRecaptcha
verifyRecaptcha(apiBaseUrl: string, nonce: string, token: string)
Parameters :
Name Type Optional
apiBaseUrl string No
nonce string No
token string No
Returns : Observable<HttpResponse<ServerPayload>>
import { Injectable } from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';

// payload returned from the server
@Injectable()
export class ServerPayload {
    nonce: string;
    token: string;
}

@Injectable()
export class RecaptchaDataService {
  constructor(private httpClient: HttpClient) { }

  public verifyRecaptcha(apiBaseUrl: string,
                          nonce: string,
                          token: string): Observable<HttpResponse<ServerPayload>> {
      return this.httpClient
          .post<ServerPayload>(
              apiBaseUrl + '/verify/captcha',
              { nonce: nonce, token: token },
              { observe: 'response' });
  }
}

result-matching ""

    No results matching ""