POST http://localhost:5001/api/v1/identity/login 500 (Internal Server Error) LoginForm.jsx:39 Error: Request failed with status code 500 at createError (createError.js:16) at settle (settle.js:17) at XMLHttpRequest.handleLoad (xhr.js:61)
import React from 'react';
import axios, { post } from 'axios';
import CONST from '../CONST';
class Upload extends React.Component {
constructor(props) {
super(props);
this.state = {
file: null,
};
this.onFormSubmit = this.onFormSubmit.bind(this);
this.onChange = this.onChange.bind(this);
this.fileUpload = this.fileUpload.bind(this);
}
onFormSubmit(e) {
e.preventDefault();
this.fileUpload(this.state.file);
}
onChange(e) {
this.setState({ file: e.target.files[0] });
}
fileUpload(file) {
let data = new FormData();
data.append('data', file);
axios
.post(`https://api.graph.cool/file/v1/${CONST.projectID}`, data, {
headers: {
'Content-Type': 'multipart/form-data',
},
})
.then(response => {
console.log('file upload response', response);
});
}
render() {
return (
<form onSubmit={this.onFormSubmit}>
<h1>File Upload</h1>
<input type="file" onChange={this.onChange} />
<button type="submit">Upload</button>
</form>
);
}
}
export default Upload; axios.post(
config.apiGateway.URL + ".../signin",
payload
).then(response => {
console.log(response)
if(response.status == 200){
console.log("Login successfull");
this.setState({token: response.data.JWT_TOKEN});
} else {
console.log(response.status)
this.setError()
}
}).catch(error => {
this.setError()
console.log(error)
if (error.response) {
console.log("--------------------------------------------------")
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
console.log("*************************")
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.log(error.request);
} else {
console.log("++++++++++++++++++++++++")
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
console.log(error.config);
})