前提
Vue.jsを用いてコンタクトフォームを作成しています。
googleフォーム経由で取得できるようにしたいのですが、400エラーが出てうまくいきません。
実現したいこと
- googleフォーム経由でお問い合わせ内容の取得
発生している問題・エラーメッセージ
Error: Request failed with status code 400 at createError (webpack-internal:///./node_modules/axios/lib/core/createError.js:16:15) at settle (webpack-internal:///./node_modules/axios/lib/core/settle.js:17:12) at XMLHttpRequest.onloadend (webpack-internal:///./node_modules/axios/lib/adapters/xhr.js:66:7)
該当のソースコード
javascript
1<script> 2import axios from "axios"; 3export default { 4 name: "contact", 5 data() { 6 return { 7 form: { 8 name: "", 9 email: "", 10 message: "", 11 }, 12 formInfo: { 13 action: 14 "https://docs.google.com/forms/.../formResponse", 15 name: "entry.20056XXXXX", 16 email: "entry.10457XXXXX", 17 message: "entry.83933XXXXX, 18 }, 19 checked: false, 20 }; 21 }, 22 23 methods: { 24 submitForm() { 25 if ( 26 this.form.name && 27 this.form.email && 28 this.form.message && 29 this.checked 30 ) { 31 const submitParams = new FormData(); 32 33 Object.keys(this.form).forEach((key) => { 34 submitParams.append(this.formInfo[key], this.form[key]); 35 }); 36 37 const CORS_PROXY = "https://sheltered-castle-40244.herokuapp.com/"; 38 const GOOGLE_FORM_ACTION = this.formInfo.action; 39 40 axios 41 .post(CORS_PROXY + GOOGLE_FORM_ACTION, submitParams) 42 .then(() => { 43 console.log("送信しました"); 44 this.$router.push("Thanks"); 45 }) 46 .catch((e) => { 47 console.log(e); 48 alert("送信に失敗しました"); 49 }); 50 } 51 }, 52 }, 53}; 54</script>
試したこと
- CORSプロキシの設定
- FormDataを作成して、objectやjsonなどに変更
よろしくおねがいします。

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/03/20 08:42