【发布时间】:2022-01-11 11:55:47
【问题描述】:
我的 Url 参数太大。所以我试图通过在request.body 中传递它来获取该内容。 API 在测试时可以与 postman 一起正常工作。但无法在 React
我正在使用 ExpressJS
API: http://localhost:5000/api/v1
反应代码:
let result = await fetch("http://localhost:8080/autocomplete",{
method: 'GET',
body: {
"text": "something new"
}
});
console.log(await result.json()) // Not get my data here
错误:
TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have a body.
我如何解决这个问题?
【问题讨论】:
-
使用方法:'POST'而不是GET
标签: javascript reactjs get header fetch