import { fetch } from 'wix-fetch'; export function getAccessToken(code) { const LINE_CHANNEL_ID = 'YOUR_CHANNEL_ID'; const LINE_CHANNEL_SECRET = 'YOUR_CHANNEL_SECRET'; const REDIRECT_URI = 'YOUR_REDIRECT_URI'; const tokenPayload = { grant_type: 'authorization_code', code: code, redirect_uri: REDIRECT_URI, client_id: LINE_CHANNEL_ID, client_secret: LINE_CHANNEL_SECRET }; return fetch('https://api.line.me/oauth2/v2.1/token', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams(tokenPayload) }) .then(response => { if (!response.ok) throw new Error('Network response was not ok'); return response.json(); }); }