Skip to content

Instantly share code, notes, and snippets.

@dnkm
Last active March 15, 2018 19:32
Show Gist options
  • Save dnkm/7de490ea864f00324dadcdb34be14117 to your computer and use it in GitHub Desktop.
Save dnkm/7de490ea864f00324dadcdb34be14117 to your computer and use it in GitHub Desktop.
yoon homework
const loadData = (cb) => {
const req = new XMLHttpRequest();
const url = "https://yoon2-hastedk.c9users.io/team/manu";
req.onreadystatechange = () => {
console.log("received", req.readyState, req.status);
if(req.readyState == 4 && req.status == 200) {
cb(JSON.parse(req.responseText));
}
}
req.open("GET", url, true);
req.send();
}
//routes/index.js
const express = require('express')
const router = express.Router()
// 이거 추가
router.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
router.use("/team", require('./team'))
router.get("/", (req, res) => {
res.send(`hello world`);
});
router.get("*", (req, res) => {
res.send("404");
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment