我需要使用Fetch API模拟表单提交,但我还无法正常工作
这是我的代码:
const headers = new Headers({
'Content-Type': 'application/x-www-form-urlencoded','accept-language': 'en-US','cache-control': 'max-age=0',});
fetch(`/actions`,{
method: 'POST',headers: headers,body: new URLSearchParams(anObject).toString(),});
这是我要模仿的形式
<form action="/actions" method="POST" enctype="application/x-www-form-urlencoded" target="_self">
我仍然不知道如何将target属性添加到Fetch中。我不知道我在这里还缺少什么。
如果您还知道使用其他工具模拟表单提交的其他方法,请告诉我。
预先感谢