ga-wdi-boston / game-project

Other
7 stars 102 forks source link

sign-up button doesn't create anything #815

Closed ryanwk closed 7 years ago

ryanwk commented 7 years ago

I'm getting my failure console log when I try to sign in, so it's not working, what am I missing?

///api.js file:
const signUpRequest = (data) => {
  return $.ajax({
    url: config.apiOrigin + '/sign-up',
    method: 'POST',
    data
    // data: data
  })
  .done(ui.success)
  .fail(ui.failure)
}

//index.js file:
$(() => {
  $('#sign-up-modal').on('submit', function (e) {
    const data = getFormFields(this)
    e.preventDefault()
    api.signUpRequest(data)
    // api.signInRequest()
  })
})

I think everything is properly required and exported

ryanwk commented 7 years ago

this might be the culprit url: config.apiOrigin + '/sign-up',

should be: url: config.development.apiOrigin + '/sign-up',

ryanwk commented 7 years ago

that didn't do it

ryanwk commented 7 years ago

that's my config file and it's required in api.js

const config = require('./config')
'use strict'

const config = {
  apiOrigins: {
    development: 'http://tic-tac-toe.wdibos.com',
    production: 'https://ga-wdi-boston.herokuapp.com'
  }
}

module.exports = config
ryanwk commented 7 years ago

making this change didn't work either in index.js

  $('#sign-up-modal').on('submit', function (e) {
    const data = getFormFields(this)
    e.preventDefault()
    api.development.signUpRequest(data)
    // api.signInRequest()
  })
})
ryanwk commented 7 years ago

andrew had a similar issue: https://github.com/ga-wdi-boston/game-project/issues/792

I tried his solution, no luck..

'use strict'

const config = {
  apiOrigins: {
    development: 'https://tic-tac-toe.wdibos.com',
    production: 'https://aqueous-atoll-85096.herokuapp.com'
  }
}
module.exports = config
ryanwk commented 7 years ago

when I enter a username and password then click the sign-in button of my modal. I get a console.log that tells me it did not work.

Jcornmanhomonoff commented 7 years ago

I think it may have something to do with the way get-form-fields works. Try switching your function in index.js from the submit of your modal to the submit of the form.

ryanwk commented 7 years ago

my event handler wasn't point toward the credentials that my request was expecting

$(() => {
  $('#sign-up-form').on('submit', function (e) {
    const data = getFormFields(this)
    e.preventDefault()
    api.signUpRequest(data)
    // api.signInRequest()
  })
})

so we added name="#sign-up-form" within my sign-up button form and this:

                            <input name="credentials[email]" type="email" class="form-control" id="inputEmail3" placeholder="Email">
                          </div>
                        </div>
                        <div class="form-group">
                          <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
                          <div class="col-sm-10">
                            <input name="credentials[password]" type="password" class="form-control" id="inputPassword3" placeholder="Password">
                          </div>
                        </div>

also don't use this development: 'https://tic-tac-toe.wdibos.com',

config.js:

'use strict'

const config = {
  apiOrigins: {
    development: 'https://aqueous-atoll-85096.herokuapp.com',
    production: 'https://aqueous-atoll-85096.herokuapp.com'
  }
}
module.exports = config

thank you Jess!!