Guest User

Untitled

a guest
Sep 22nd, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. submit = (event) => {
  2. //console.log(this.state);
  3. axios({
  4. method: 'post',
  5. url: 'https://uxcandy.com/~shapoval/test-task-backend/create?developer=Agarkova',
  6. crossDomain: true,
  7. headers : {
  8. 'Content-Type': 'multipart/form-data'
  9. },
  10. processData: false,
  11. data: {
  12. username : "User",
  13. email: this.state.user.email,
  14. password : this.state.user.password,
  15. notes : this.state.user.notes,
  16. task : this.state.user.task,
  17. file : this.state.user.file
  18. },
  19. config: { headers: {'Content-Type': 'multipart/form-data' },
  20. onUploadProgress : progressEvent => {
  21. console.log('Upload Progress:' + Math.round(progressEvent.loaded / progressEvent.total * 100) + '%')
  22. }
  23. }
  24. }).then(function (response) {
  25. //handle success
  26. console.log(response.data);
  27. })
  28. .catch(function (response) {
  29. //handle error
  30. console.log(response);
  31. });
  32. }
  33.  
  34. let formData = new FormData();
  35. formData.append('username', "User");
  36. formData.append('email', this.state.user.email);
  37. formData.append('password', this.state.user.password);
  38. formData.append('notes', this.state.user.notes);
  39. formData.append('task', this.state.user.task);
  40. formData.append('file', this.state.user.file);
  41.  
  42. submit = (event) => {
  43. //console.log(this.state);
  44. axios({
  45. method: 'post',
  46. url: 'https://uxcandy.com/~shapoval/test-task-backend/create?developer=Agarkova',
  47. crossDomain: true,
  48. processData: false,
  49. data: formData,
  50. onUploadProgress : progressEvent => {
  51. console.log('Upload Progress:' + Math.round(progressEvent.loaded / progressEvent.total * 100) + '%')
  52. }
  53. }).then(function (response) {
  54. //handle success
  55. console.log(response.data);
  56. }).catch(function (response) {
  57. //handle error
  58. console.log(response);
  59. });
  60. }
Add Comment
Please, Sign In to add comment