// 응답 내용
{
"status":200,
"original":"안녕",
"result":"녕안",
"success":true
}
// node-fetch
let text = '뒤집을 텍스트';
const fetch = require('node-fetch')
fetch(`https://mora-bot.kr/api/v1/reverse?text=${encodeURI(text)}`)
.then(res => res.json())
.then(json => {
console.log(json)
console.log(`뒤집기 전 : ${json.original}`);
console.log(`뒤집은 후 : ${json.result}`);
});
// request
let text = '뒤집을 텍스트'
let api_url = `https://mora-bot.kr/api/v1/reverse?text=${encodeURI(text)}`
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.original}`);
console.log(`뒤집은 후 : ${json.result}`);
} else {
console.log('error = ' + response.errorcode);
}
});
import requests
response = requests.get("https://mora-bot.kr/api/v1/reverse?text=ThankYou")
result = response.json()
if response.status == 200:
print(result)
else:
print(f"Error Code: {response.errorcode}")