Guest User

Untitled

a guest
May 25th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. export default {
  2. name: "Contact",
  3. components: {
  4. FooterComponent: FooterComponent,
  5. NavigationComponent: NavigationComponent
  6. },
  7. data() {
  8. return {
  9. locale: Cookie.get('locale'),
  10. nameAndLastName: '',
  11. email: '',
  12. subject: '',
  13. message: '',
  14. showPopUp: false
  15. }
  16. },
  17. methods: {
  18. sendEmail(e) {
  19. e.preventDefault();
  20. this.$validator.validateAll();
  21. if (!this.$validator.errors.any()) {
  22. let params = new URLSearchParams();
  23. params.append('nameAndLastName', this.nameAndLastName);
  24. params.append('email', this.email);
  25. params.append('subject', this.subject);
  26. params.append('message', this.message);
  27.  
  28. axios.post(this.$apiUrl + `rest/api/public/Contact/contact`, params, {
  29. headers: {
  30. 'Content-Type': 'application/x-www-form-urlencoded'
  31. }
  32. })
  33. .then(function (response) {
  34. if (response.statusText === 'OK') {
  35. console.log(this.showPopUp);
  36. this.showPopUp = true;
  37. }
  38. })
  39. .catch(function (error) {
  40. console.log(error);
  41. // This throws error TypeError: Cannot read property 'showPopUp' of undefined
  42.  
  43. });
  44. }
  45. }
  46. },
  47. mounted: function () {
  48. console.log('test');
  49. console.log(this.showPopUp);
  50. },
  51. }
Add Comment
Please, Sign In to add comment