So I'm new in angular and I'm new with API's I tried to create thingy, where I can get video information by id, using several tutorials and browsing stackoverflow I managed to find 2 solutions to the problem, but neither of them work for me. First I tried
mvcApp.service('ApiCall', ['$http', function($http) {
var result;
this.GetApiCall = function() {
result = $http.get('https://hosting.com/webmasters/video_by_id?id=123456789')
.success(function(data) {
result = (data);
})
.error(function() {
alert('Something wrong');
});
return result;
}}]);
It uses good API link, but return No 'Access-Control-Allow-Origin' header is present on the requested resource
error.
Next solution I found was:
mvcApp.factory('json', function($http) {
return {
getInformation: function (name) {
var url = 'https://hosting.com/webmasters/video_by_id';
return $http.jsonp(url, {
params: {
id: name
}
});
}
}});
This one returns errors, as it does not recognises var as a link, and return video_by_id?id=123456789:1 Uncaught SyntaxError: Unexpected token :
error. But as I tinkered with it and looked at some other examples, found out that adding extension to links, fixes this, but I do not have or know an extension. So any help would be valuable