Closed alvarosaavedra closed 8 years ago
Ah interesting. How are you calling the action, @alvarosaavedra?
And are you seeing any inputs from your server?
OK so I have a component: Login.js
import React, { PropTypes as T } from 'react'
import {Link} from 'react-router'
import styles from './styles.module.css';
let email;
let password;
export class Login extends React.Component {
handleSubmit() {
event.preventDefault();
this.props.onSubmit(email.value, password.value)
}
render() {
return (
<div>
<h1> Login</h1>
<form className={styles.login} onSubmit={this.handleSubmit.bind(this)}>
<input type="email" ref={node => {email = node }}/>
<input type="password" ref={node => {password = node }}/>
<button>Login</button>
</form>
</div>
)
}
}
Login.propTypes = {
onSubmit: T.func
}
Login.defaultProps = {
}
export default Login
For this component I use a container: SignIn.js
import { connect } from 'react-redux'
import Login from '../../components/Login/Login'
const mapDispatchToProps = (dispatch, ownProps) => {
return {
onSubmit: (email,password) => {
ownProps.actions.auth.signIn({email:email, password: password});
}
}
}
const SignIn = connect(
mapDispatchToProps
)(Login)
export default SignIn
then I have the auth redux-module:
import {createConstants, createReducer} from 'redux-module-builder'
import {createApiHandler, createApiAction} from 'redux-module-builder/api'
import { normalize, Schema, arrayOf } from 'normalizr';
export const types = createConstants('auth')(
{ 'SIGN_IN': {api: true}}
);
export const actions = {
signIn: createApiAction(types.SIGN_IN)((client, {email,password}) => {
console.debug(email,password)
return client.post({
path: '/school/sessions',
data: {user_session: "HOla"}
}).then(res => {console.debug(res); return res})
})
}
/* TODO */
export const reducer = createReducer({
[types.SIGN_IN]: (state, {email, password}) => ({
...state,
email: email
})
});
export const initialState = {
loading: false,
errors: null,
email: null,
token: null
};
At the backend the request come as POST request, and I dont get any data in the request just the url. When doing a get one everithing works as espected. I see that all your test ar for get, and not for post. Could be some implementation there??? I'm using the data param in the rigth way??
Can you try something for me? Not sure how this "got" in the way, but can you try changing line 52 and 54 in apiClient
to read with opts
, instead of baseOpts
?
Do you have a gchat id? I'd be willing to jump on gchat with you to try to work it out. I'll see if I can mimic that behavior over here/tests. Thanks for reporting!
@alvarosaavedra yes, you're using the data
param properly. It is sent as the body
parameter.
@auser thnx I change the lines in the node modules (they are diferent lines) just for try, it dosen't work, my gchat is asaabe@gmail.com, if you are interested. I also put the debug mode on, nothing importan I think, and in the developer tools of chrome the request it seem to bee empty also.
var requestTransforms = _this._parseOpt('requestTransforms', options, opts, []);
var responseTransforms = _this._parseOpt('responseTransforms', options, opts, [parseJson]);
I just sent you a message on gchat. Feel free to ping me on there.
What does the debugLog say is in the transformedOpts
?
requesting...
0.0.0.0/:1 POST http://0.0.0.0:5000/api-token-auth/ 400 (Bad Request)
apiClient.js?8a29:159 Response {type: "cors", url: "http://0.0.0.0:5000/api-token-auth/", status: 400, ok: false, statusText: "Bad Request"…}
Thanks @alvarosaavedra
Pushed 0.3.2
to fix this bug.
I can't make it work, I asume that shuold be somethink like
but I not reciving any inputs