Last active
March 15, 2018 19:32
-
-
Save dnkm/7de490ea864f00324dadcdb34be14117 to your computer and use it in GitHub Desktop.
yoon homework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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