Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 732 Bytes

rails_ujs.md

File metadata and controls

30 lines (24 loc) · 732 Bytes
import Rails from '@rails/ujs';
import { Controller } from "stimulus"

export default class extends Controller {
  static targets = [ "recaptchaToken" ]

  greet() {
    let recaptcha_token  = this.recaptchaTokenTarget.value

    Rails.ajax({
      type: 'post',
      url: 'http://localhost:3001/v3/email_authentication',
      data: `recaptcha_token=${recaptcha_token}`,
      dataType: 'json',
      success: function(data) {
        console.log(data);
      },
      error: function(data) {
        alert(data);
      }
    })
  }
}