我正在嘗試將資料從反應發送到快遞服務器。
反應代碼:
const imageRenderer = async () => {
const res = await axios({
method: "post",
url: "http://localhost:8080/previewRender",
data: selectedFile.filePaths,
});
console.log(res.data);
};
快遞代碼:
app.post("/previewRender", (req, res) => {
var fileLocation = req.body;
console.log(fileLocation);
});
但是在控制臺中,檔案位置顯示為未定義。selectedFile.filePaths 是物件型別。不能發物件快遞嗎?
uj5u.com熱心網友回復:
將此添加到 app.js(app.js)或應用程式的根檔案中以發布請求
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
把這個中間件放在app.js你的路線之上......
uj5u.com熱心網友回復:
你app.use(express.json())在你的 app.js 中使用了嗎?
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/337032.html
標籤:javascript 节点.js 反应 表达
