Fetch API cannot load http://echo.websocket.org/. No 'Access-Control-Allow-Origin'
RylanGotto opened this issue · 0 comments
Fetch API cannot load http://echo.websocket.org/. No 'Access-Control-Allow-Origin'
This is how I am defining everything just for a test in an angular seed project.
For some reason it made me define the buffer type for some reason, in which case I am getting the following
Fetch API cannot load http://echo.websocket.org/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8200' is therefore not allowed access. The response had HTTP status code 404. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Any tips would be greatly appreciated.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
'use strict';
angular.module('dgmd.game.view', ['ngRoute', 'angular-websocket'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/game', {
templateUrl: 'game/game.html',
controller: 'GameCtrl'
});
}])
.controller('GameCtrl', ['$websocket', function($websocket) {
var dataStream = $websocket('ws://echo.websocket.org', [], {binaryType: "arraybuffer"});
var collection = [];
dataStream.onMessage(function(message) {
collection.push(JSON.parse(message.data));
});
dataStream.onOpen(function(message) {
console.log('open')
});
}]);