i started build hangman game. found great wordnik api should allow me random words. here's code on codepen. not understand why keep getting raw html instead of word. tried fix content-type: application/json
but didn't work.
html
<body layout="column" ng-app="myapp" ng-cloak ng-controller="controller"> <h1>{{title}}</h1> {{words}} </body>
css
h1 { font-family: 'nosifer', cursive; text-align: center; font-size: 2em; }
js
var myapp = angular.module('myapp', ['ngmaterial']); myapp.controller('controller', ['$scope', '$http', function($scope, $http) { $scope.title = "hangman"; $http({ method: 'get', url: "https://crossorigin.me/http://api.wordnik.com/words.json/randomword?minlength=5&api_key=c3847c4934574ce6cf81c45640103f2e5fab2284ab2e7badc" }) .then(function(response) { $scope.words = response.data; }, function errorcallback(response) {}) }]);
you used bad url, literally 2 urls :)
try url:
"http://api.wordnik.com:80/v4/words.json/randomword?api_key=c3847c4934574ce6cf81c45640103f2e5fab2284ab2e7badc"
then json response.
Comments
Post a Comment