-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (39 loc) · 1.11 KB
/
Copy pathindex.js
File metadata and controls
42 lines (39 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const btn = document.getElementById('btn');
const liffId = '';
let userId = '';
function main(){
// 1.liff init
// 2.get profile
liff.init({liffId: liffId});
liff.ready.then(() => {
if(!liff.isLoggedIn()){
liff.login();
}
liff.getProfile().then((profile) => {
userId = profile.userId;
console.log(profile);
});
});
}
main()
async function send(e){
e.preventDefault();
const firstname = document.getElementById('firstname').value;
const lastname = document.getElementById('lastname').value;
const email = document.getElementById('email').value;
// 3. axios post data
try {
const result = await axios.post('http://localhost:3000/api/v1/change-richmenu', {
firstname: firstname,
lastname: lastname,
email: email,
userId: userId
});
if(result.status == 200){
console.log("closeWindow");
// liff.closeWindow();
}
} catch (error) {
console.log(error);
}
}