简体   繁体   中英

Bad Request React Axios 400

Can Anyone tell me why I am having this error??

the error is status code 400 bad request

This could be on the server?

I am new with react

handleSubmit(event, _success, _error) {
    event.preventDefault();

    var data = {
      FriendlyName: this.state.FriendlyName,
      full_name: this.state.full_name,
      email: this.state.email,
    };

    const config = {
      method: 'post',
      url:
        'https://taskrouter.twilio.com/v1/Workspaces/{<WorkerSid>}/Workers',
      headers: {
        Authorization:
          'Basic QUM1MmNiOTIxNGQwY2ZmMjA4NjBiZDdjMTQ5Y2Q4NjBlNTpmODRmOWJiOGFlZjI4MWFmZDY2NGY4NTY1OGYwNzJhOA==',
        'Content-Type': 'application/x-www-form-urlencoded',
      },
      data: data,
    };

    axios(config)
      .then(() => {
        console.log('data', data);
        if (Object.keys(data).length > 0) {
          if (typeof _success === 'function') _success(data);
        } else {
          if (typeof _error === 'function')
            _error({ error: 'Não houve nenhum retorno.' });
        }
      })
  }

Try backticks instead of apostrophe url:'https://taskrouter.twilio.com/v1/Workspaces/{<WorkerSid>}/Workers'

const config = {
      method: 'post',
      url:
        'https://taskrouter.twilio.com/v1/Workspaces/{<WorkerSid>}/Workers',
      headers: {
        Authorization:
          'Basic QUM1MmNiOTIxNGQwY2ZmMjA4NjBiZDdjMTQ5Y2Q4NjBlNTpmODRmOWJiOGFlZjI4MWFmZDY2NGY4NTY1OGYwNzJhOA==',
        'Content-Type': 'application/x-www-form-urlencoded',
      },
      data: data,
    };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM