Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught SyntaxError: Unexpected token '<' #62

Closed
jodiedoubleday opened this issue Mar 16, 2020 · 1 comment
Closed

Uncaught SyntaxError: Unexpected token '<' #62

jodiedoubleday opened this issue Mar 16, 2020 · 1 comment

Comments

@jodiedoubleday
Copy link

jodiedoubleday commented Mar 16, 2020

I see this was fixed in #2 but it seems to still be happening for me using 5.1.2

Example code:

export default class IndexPage extends React.Component {

  state = {
    email: null,
    firstname: null,
    lastname: null
  }

  _handleChange = (e) => {
    this.setState({
      [`${e.target.name}`]: e.target.value,
    });
  }
  _handleSubmit = e => {
    e.preventDefault()

    console.log('submit', this.state)
    addToMailchimp(this.state.email, {
      FNAME: this.state.firstname,
      LNAME: this.state.lastname
    })
    .then(({ msg, result }) => {
      console.log('msg', `${result}: ${msg}`)

      if (result !== 'success') {
        throw msg
      }
      alert(msg)
    })
    .catch(err => {
      console.log('err', err)
      alert(err)
    })
  }
  render() {
    return (
      <form onSubmit={this._handleSubmit}>
        <div className='form-group'>
          <label htmlFor='email'>Email Address</label>
          <input type='email' name='email' className='form-control' id='email' aria-required='true' onChange={this._handleChange} />
        </div>
        <div className='form-group'>
          <label htmlFor='firstname'>First Name</label>
          <input type='text' name='firstname' className='form-control' id='firstname' aria-required='true' onChange={this._handleChange} />
        </div>
        <div className='form-group'>
          <label htmlFor='lastname'>Last Name</label>
          <input type='text' name='lastname' className='form-control' id='lastname' aria-required='true' onChange={this._handleChange} />
        </div>
      </form>
    )
  }
}
@jodiedoubleday
Copy link
Author

Figured it out, i was being an idiot, i didn't fill out the endpoint correctly and so it was 404'ing.

I'll get my coat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant