forked from daren.hsu/line_push
17 lines
531 B
TypeScript
17 lines
531 B
TypeScript
import querystring from 'querystring'
|
|
|
|
const ENDPOINT = 'https://json_2series.digitalent.tw/users'
|
|
|
|
export default {
|
|
async middleware({ req, res, error, $axios, redirect }) {
|
|
const url: URL = new URL(req.url, `https://${req.headers.host}`)
|
|
const uid: string = url.searchParams.get('LINEUserID') || ''
|
|
|
|
const response = await $axios.get(ENDPOINT, {
|
|
params: { LINEUserID: uid }
|
|
})
|
|
res.setHeader('Content-Type', 'application/json; charset=utf-8')
|
|
res.end(JSON.stringify(response.data.slice(-1)))
|
|
}
|
|
}
|