SPFX React JS POST REST Call not working - Cannot read property 'post' of undefined

Copper Contributor

I am trying to authenticate username and password only to a public Authorization.

It is always throwing error - "Cannot read property 'post' of undefined".

I have used

this.context.httpClient.POST( postURL,  HttpClient.configurations.v1,   httpClientOptions)

Below is the request body and headers 

 

const body: string = JSON.stringify({
    'username': value1,
    'password': value2,
    'options': value3,
  });

  const requestHeaders: Headers = new Headers();
  requestHeaders.append('Content-type''application/json');
  requestHeaders.append('Accept''application/json');
  requestHeaders.append('Cache-Control''no-cache');

  requestHeaders.append('User-Agent''PostmanRuntime/7.20.1');
  requestHeaders.append('Postman-Token''xxxxxxxxxxxxxxxxxxxxxxxxxx');
  requestHeaders.append('Host''xxxxxx.oktapreview.com');
  requestHeaders.append('Accept-Encoding''gzip, deflate');
  requestHeaders.append('Content-Length''161');
  requestHeaders.append('Cookie''xxxxxx=xxxxxxxxxxxxxxxxxxxxx');
  requestHeaders.append('Connection''keep-alive');
0 Replies