本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
如何使用整合fetch
包裝
您可以通過更改AwsWafIntegration
命名空間下的 fetch
API 的常規fetch
調用來使用 AWS WAF fetch
包裝器。 AWS WAF 包裝器支援與標準 JavaScript fetch
API 呼叫相同的所有選項,並為整合新增權杖處理。這種方法通常是整合應用程式的最簡單方法。
在包裝實現之前
下列範例清單會顯示實作AwsWafIntegration
fetch
包裝函式之前的標準程式碼。
const login_response = await fetch(login_url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: login_body });
包裝實現之後
下列清單顯示了AwsWafIntegration
fetch
包裝函式實作的相同程式碼。
const login_response = await AwsWafIntegration.fetch(login_url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: login_body });