How to use the integration fetch wrapper - Amazon WAF, Amazon Firewall Manager, and Amazon Shield Advanced
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

How to use the integration fetch wrapper

This section provides instructions for using the integration fetch wrapper.

You can use the Amazon WAF fetch wrapper by changing your normal fetch calls to the fetch API under the AwsWafIntegration namespace. The Amazon WAF wrapper supports all of the same options as the standard JavaScript fetch API call and adds the token handling for the integration. This approach is generally the simplest way to integrate your application.

Before the wrapper implementation

The following example listing shows standard code before implementing the AwsWafIntegration fetch wrapper.

const login_response = await fetch(login_url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: login_body });
After the wrapper implementation

The following listing shows the same code with the AwsWafIntegration fetch wrapper implementation.

const login_response = await AwsWafIntegration.fetch(login_url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: login_body });