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
已提問 1 年前檢視次數 1116 次
2 個答案
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
已回答 1 年前
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
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南