ga-wdi-boston / full-stack-project

Other
8 stars 64 forks source link

Deployed page undefined #1050

Closed jillrizley closed 7 years ago

jillrizley commented 7 years ago

getting this error on my deployed page, saying undefined again and I'm not totally sure where it's coming from

'/full-stack-project-front-end/undefinedsign-up Failed to load resource: the server responded with a status of 405 ()'

config

'use strict'

const config = {
  apiOrigins:
  {
    development: 'https://localhost:4741',
    production: 'https://shrouded-reef-79923.herokuapp.com'
  }
}
module.exports = config

api

const signUp = function (data) {
  console.log(config.apiOrigins)
  return $.ajax({
    url: config.apiOrigins + '/sign-up/',
    method: 'POST',
    data
  })
}
jordanallain commented 7 years ago

When are you getting the error?

jordanallain commented 7 years ago

To be clear, the config object should have a key apiOrigins (plural) that points to your two urls for your API (local and deployed).

You should be sending your Ajax requests to apiOrigin (singular) which is a method that selects one of those two urls based on your environment (local or deployed).

You're currently trying to send the request to apiOrigins which is an object. (Based on the code above)

jordanallain commented 7 years ago

Hence the [object Object] in your request.

payne-chris-r commented 7 years ago

+1 to Jordan's suggestion.