mirror of
https://github.com/brettstack/civ6-play-by-cloud-turn-notifier.git
synced 2026-04-03 03:00:02 -04:00
31 lines
751 B
JavaScript
31 lines
751 B
JavaScript
const path = require('path')
|
|
|
|
const dotenvPath = path.resolve(__dirname, '../.env.development')
|
|
require('dotenv').config({ path: dotenvPath })
|
|
const fetch = require('node-fetch')
|
|
|
|
const {
|
|
GAME_ID,
|
|
API_GATEWAY_ENDPOINT,
|
|
} = process.env
|
|
|
|
const WEBHOOK_REQUEST_VALUE = {
|
|
value1: 'Free-for-all',
|
|
value2: 'Brett',
|
|
value3: Math.round(Math.random(0, 100) * 100).toString(),
|
|
}
|
|
async function main() {
|
|
const endpoint = `webhook?gameId=${GAME_ID}`
|
|
const url = `${API_GATEWAY_ENDPOINT}/${endpoint}`
|
|
|
|
const response = await fetch(url, {
|
|
body: JSON.stringify(WEBHOOK_REQUEST_VALUE),
|
|
method: 'POST',
|
|
headers: { 'content-type': 'application/json' },
|
|
})
|
|
const responseBody = await response.text()
|
|
console.log(responseBody)
|
|
}
|
|
|
|
main()
|