如何在箭头函数中添加多个参数
How to add multiple parameters in arrow function
已经对我的愚蠢问题感到抱歉,但谷歌搜索没有成功
如何在箭头函数中添加多个参数。我想给下面的函数添加一些属性“props”。
const changeLocationHandler = async event => {
try {
let hasError = false;
let response = await fetch('http://localhost:5000/api/game/location', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + auth.token
},
body: {
}
});
const responseData = await response.json();
if (!response.ok) {
hasError = true;
}
if (hasError) {
alert(responseData.message);
}
} catch (error) {
alert(error)
}
}
不接受
const changeLocationHandler = async event props => {
或
const changeLocationHandler = props => async event => {
提前致谢
您需要将参数括在括号中才能正常工作。
const changeLocationHandler = async (event, arg2, arg3) => {
已经对我的愚蠢问题感到抱歉,但谷歌搜索没有成功
如何在箭头函数中添加多个参数。我想给下面的函数添加一些属性“props”。
const changeLocationHandler = async event => {
try {
let hasError = false;
let response = await fetch('http://localhost:5000/api/game/location', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + auth.token
},
body: {
}
});
const responseData = await response.json();
if (!response.ok) {
hasError = true;
}
if (hasError) {
alert(responseData.message);
}
} catch (error) {
alert(error)
}
}
不接受
const changeLocationHandler = async event props => {
或
const changeLocationHandler = props => async event => {
提前致谢
您需要将参数括在括号中才能正常工作。
const changeLocationHandler = async (event, arg2, arg3) => {