so i'm new in angular , i'm new api's tried create thingy, can video information id, using several tutorials , browsing stackoverflow managed find 2 solutions problem, neither of them work me. first 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 api link, return no 'access-control-allow-origin' header present on requested resource
error.
next solution 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 1 returns errors, not recognises var link, , return video_by_id?id=123456789:1 uncaught syntaxerror: unexpected token :
error. tinkered , looked @ other examples, found out adding extension links, fixes this, not have or know extension. valuable
if api not in same server angular code, handle cors on requested resource, avoid error.
Comments
Post a Comment