Created
February 23, 2019 09:59
-
-
Save r3-yamauchi/7b3d85901568891768131bc2feb2ae57 to your computer and use it in GitHub Desktop.
LIFF を使って LINE から簡単に kintone データにアクセスする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = new Vue({ | |
el: '#app', | |
data: { | |
message: "こんにちは", | |
userId: "", | |
displayName: "", | |
accessToken: "", | |
scope: "", | |
client_id: "", | |
expires_in: "" | |
}, | |
created() { | |
const that = this; | |
liff.init( | |
data => { | |
that.userId = data.context.userId; | |
that.message = "初期化できたし"; | |
return liff.getProfile() | |
.then(profile => { | |
that.message = "プロフィール採れたし"; | |
that.userId = profile.userId; | |
that.displayName = profile.displayName; | |
const accessToken = liff.getAccessToken(); | |
if (!accessToken) { | |
that.message = "アクセストークンを取得できません"; | |
return; | |
} | |
that.accessToken = accessToken; | |
that.message = "トークン採れたし"; | |
return axios({ | |
method: "POST", | |
url: 'サーバーのURL', | |
data: {}, | |
headers: { | |
'Content-Type': 'application/json', | |
'accessToken': accessToken | |
} | |
}).then(response => { | |
that.message = "完了"; | |
}); | |
}) | |
.catch(err => { | |
that.message = "Error\n" + err.code + "\n" + err.message; | |
}); | |
}, | |
err => { | |
that.message = "Error\n" + err.code + "\n" + err.message; | |
} | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment