Last active
December 6, 2018 19:11
-
-
Save cbejensen/cb23a2bb102cd8d7dc5ac0c6d7005f90 to your computer and use it in GitHub Desktop.
Getting no response when sending GET request from localhost:3000 to localhost:8000
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
// currently running on localhost:3000 | |
const xhr = new XMLHttpRequest() | |
const url = 'localhost:8000/' | |
xhr.open('GET', url) | |
xhr.onreadystatechange = function() { | |
console.log(xhr.responseText) // logs nothing | |
} | |
xhr.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
const express = require('express') | |
const cors = require('cors') | |
const app = express() | |
const port = 8000 | |
app.use(cors()) | |
app.get('/', (req, res) => { | |
console.log('got a get request') // never logs | |
res.send('ok') | |
}) | |
app.listen(port, () => console.log(`Example app listening on port ${port}!`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment