// 응답 내용
{
"status":200,
"minimum":"1",
"maximum":"5",
"result":2,
"code":"9fcbd626-eb8c-4daf-b927-f3913d19f17b",
"success":true
}
// node-fetch
let min = 0;
let max = 10;
const fetch = require('node-fetch')
fetch(`https://mora-bot.kr/api/v1/randomnumber?min=${min}&max=${max}`)
.then(res => res.json())
.then(json => {
console.log(json)
console.log(`최소값 : ${json.minimum}`);
console.log(`최대값 : ${json.maximum}`);
console.log(`결과 : ${json.result}`);
});
// request
let min = 0;
let max = 10;
let api_url = `https://mora-bot.kr/api/v1/randomnumber?min=${min}&max=${max}`
const request = require('request');
let options = {
url: api_url
}
request.get(options, function (error, response, body) {
if (!error && response.status == 200) {
let json = JSON.parse(body)
console.log(`최소값 : ${json.minimum}`);
console.log(`최대값 : ${json.maximum}`);
console.log(`결과 : ${json.result}`);
} else {
console.log('error = ' + response.errorcode);
}
});
import requests
response = requests.get("https://mora-bot.kr/api/v1/randomnumber?min=0&max=10")
result = response.json()
if response.status == 200:
print(result)
else:
print(f"Error Code: {response.errorcode}")