###エラーの内容はうまく読み取れませんでしたが
###どうやら6行目の”)”がどうなの?と示してくれているようです。
console
bootstrap:83 Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /Users/maedatakuo/projects/payjp_practice/app/javascript/card.js: Missing semicolon (6:5)
4 | e.preventDefault();
5 | console.log("カード情報トークン化のためのJavaScript")
> 6 | });
| ^
7 | };
8 |
9 | window.addEventListener("load", pay)
at Parser._raise (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:776)
at Parser.raiseWithData (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:769)
at Parser.raise (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:737)
at Parser.semicolon (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:9718)
at Parser.parseExpressionStatement (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12804)
at Parser.parseStatementContent (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12396)
at Parser.parseStatement (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12260)
at Parser.parseBlockOrModuleBlockBody (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12846)
at Parser.parseBlockBody (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12837)
at Parser.parseBlock (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12821)
at Parser.parseFunctionBody (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:11778)
at Parser.parseArrowExpression (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:11750)
at Parser.parseParenAndDistinguishExpression (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:11323)
at Parser.parseExprAtom (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:11027)
at Parser.parseExprSubscripts (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:10709)
at Parser.parseUpdate (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:10689)
at Parser.parseMaybeUnary (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:10667)
at Parser.parseExprOps (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:10524)
at Parser.parseMaybeConditional (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:10498)
at Parser.parseMaybeAssign (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:10461)
at Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:10428
at Parser.allowInAnd (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12099)
at Parser.parseMaybeAssignAllowIn (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:10428)
at Parser.parseVar (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12927)
at Parser.parseVarStatement (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12741)
at Parser.parseStatementContent (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12327)
at Parser.parseStatement (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12260)
at Parser.parseBlockOrModuleBlockBody (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12846)
at Parser.parseBlockBody (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12837)
at Parser.parseProgram (Users/maedatakuo/projects/payjp_practice/node_modules/@babel/parser/lib/index.js:12191)
at Object../app/javascript/card.js (bootstrap:83)
at __webpack_require__ (bootstrap:19)
at Object../app/javascript/packs/application.js (application.js:10)
at __webpack_require__ (bootstrap:19)
at bootstrap:83
at bootstrap:83
でも最終的には
(誤)
javascript
const pay = () => {
const form = document.getElementById("charge-form");
form.addEventListener("submit"), (e) => {
e.preventDefault();
console.log("カード情報トークン化のためのJavaScript")
});
};
window.addEventListener("load", pay)
4行目の("submit")のうしろの ")"が余分でこれをとると
(正)
javascript
const pay = () => {
const form = document.getElementById("charge-form");
form.addEventListener("submit", (e) => {
e.preventDefault();
console.log("カード情報トークン化のためのJavaScript")
});
};
window.addEventListener("load", pay)
通りました。