Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. private loggerUrl = 'localhost:3039/read/getall/';
  2. getLoggerData(): Promise <Dataset[]> {
  3. return this.http.get(this.loggerUrl)
  4. .toPromise()
  5. .then(response => response.json().data as Dataset[])
  6. .catch(this.handleError);
  7. }
  8.  
  9. var app = express();
  10.  
  11. app.use(function (req, res, next) {
  12.  
  13. //Website you wish to allow to connect
  14. res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3035');
  15.  
  16. // Request methods you wish to allow
  17. res.setHeader('Access-Control-Allow-Methods',
  18. 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
  19.  
  20. // Request headers you wish to allow
  21. res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
  22.  
  23. // Set to true if you need the website to include cookies in the requests sent
  24. // to the API (e.g. in case you use sessions)
  25. res.setHeader('Access-Control-Allow-Credentials', true);
  26.  
  27. // Pass to next layer of middleware
  28. next();
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement