WAF bot control javascript integration in React

0

Hi. Has anybody been successful in implementing WAF integration in React pages? I'm told there isn't a npm package, but due to the way we're building I'm getting a not defined errors. We're trying out Bot Control and integrating it with javascript SDK. But we're having trouble comiling our application. We use React to make our web app.

I have added <script> section as instructed in documentation and tried to replace fetch call with AwsWafIntegration.fetch However I get an error:

ReferenceError: AwsWafIntegration is not defined

And my code: const response = await AwsWafIntegration.fetch(url, config)

Artur
asked a year ago1081 views
2 Answers
0

Hi Artur,

re-checked based on your information and I built a small demo that works without such error. I would advice to check the Console page of your browser's inspect feature and see if there are any errors showing up.

AWS
answered a year ago
0

Hi Artur - perhaps you are using Typescript? I managed to get this working adding a declaration in a .d.ts file. The typing matches exactly fetch's usual typing.

  declare namespace AwsWafIntegration {
    declare function fetch(
      input: RequestInfo | URL,
      init?: RequestInit | undefined
    ): Promise<Response>;
  }
Ben
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions