Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fetch('http://localhost:8080/login', {
- method: 'POST',
- mode:'cors',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- username: this.state.username,
- password: this.state.password
- })
- });
- var responseHeaders = {
- "access-control-allow-origin": "*",
- "access-control-allow-methods": "GET, POST, PUT, DELETE, OPTIONS",
- "access-control-allow-headers": "content-type, accept",
- "access-control-max-age": 10,
- "Content-Type": "application/json"
- };
- app.post('/login', function(req, res, next) {
- if (req.method == "OPTIONS") {
- res.writeHead(statusCode, responseHeaders);
- res.end();
- }
- console.log("hello");
- ...
- OPTIONS /login 200 8.570 ms - 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement