This repository has been archived on 2023-08-08. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
tatoeba-api-node/index.js
2022-06-21 21:37:27 -07:00

17 lines
490 B
JavaScript

const app = require("express")();
app.use(require("cors")());
const fetch = require("node-fetch");
app.get("/", (request, response) => {
response.writeHead(200, { "Content-Type": "application/json" });
const term = "漢字";
fetch("https://tatoeba.org/en/api_v0/search" + request.url.substring(request.url.indexOf("?")))
.then(response => response.text())
.then(body => {
response.write(body);
response.end();
});
});
app.listen(process.argv[2] ? process.argv[2] : 3000);