-2

already sorry for my stupid question but googling for it was not successful

How can I add multiple parameters in an arrow functions. I want to add some properties "props" to the following function.

  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)
    }
  }

It does not accept someting like

const changeLocationHandler = async event props => {

or

const changeLocationHandler = props => async event => {

Thanks in advance

Sam Simon
  • 5
  • 1
  • 3

1 Answers1

1

You need to wrap the arguments in parentheses for this to work.

const changeLocationHandler = async (event, arg2, arg3) => {
Keimeno
  • 2,512
  • 1
  • 13
  • 34