vigour-io / api

0 stars 0 forks source link

Setting the value doesnt fire the post request #50

Closed rickiesmooth closed 8 years ago

rickiesmooth commented 8 years ago

I declared the following API method:

exports['facebook-login'] = {
  url: {
    $add: 'login/facebook'
  },
  inject: userData
}

To POST the user token that I receive from facebook, I do the following:

facebook.user.token.on('data', function () {
  element.api['facebook-login'].set(facebook.user.token.val)
})

Unfortunatly this doesn't work, and when I try to use it in my modal data, it also doesn't work:

module.exports = {
  title: ['$', 'text', 'acount', 'signin', 'title'],
  logo: true,
  buttons: {
    order: 2,
    signin: ['$', 'modals', 'login'],
    facebook: {
      title: 'Login met facebook',
      api: 'facebook-login',
      data: facebook.user.token.val,
      buttonType: 'submit'
    }
  }
}

The last method is probably totally wrong, but I expected that the first method should work. What am I doing wrong @jimdebeer

jimdebeer commented 8 years ago

using .val parses the value so from that moment its not being observed anymore fix by remove.val -- if this does not work take it up with marcus and check if the facebook api fires

also this is wrong

facebook.user.token.on('data', function () {
  element.api['facebook-login'].set(facebook.user.token.val)
})

since for now as mentioned in other issues in api you can only use references (not straight values), you don't need to listen specificly on facebook.token.val when you use this

module.exports = {
  title: ['$', 'text', 'acount', 'signin', 'title'],
  logo: true,
  buttons: {
    order: 2,
    signin: ['$', 'modals', 'login'],
    facebook: {
      title: 'Login met facebook',
      api: 'facebook-login',
      data: facebook.user.token, ///<---- look different!
      buttonType: 'submit'
    }
  }
}