Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 3650723

Browse files
andypottsgkalpak
authored andcommitted
docs(guide/concepts): simplify currency exchange API example (YQL --> Fixer.io)
Fixes #16130 Closes #16137
1 parent aee5d02 commit 3650723

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

docs/content/guide/concepts.ngdoc

+5-14
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Right now, the `InvoiceController` contains all logic of our example. When the a
186186
is a good practice to move view-independent logic from the controller into a
187187
<a name="service">{@link services service}</a>, so it can be reused by other parts
188188
of the application as well. Later on, we could also change that service to load the exchange rates
189-
from the web, e.g. by calling the Yahoo Finance API, without changing the controller.
189+
from the web, e.g. by calling the [Fixer.io](http://fixer.io) exchange rate API, without changing the controller.
190190

191191
Let's refactor our example and move the currency conversion into a service in another file:
192192

@@ -300,7 +300,7 @@ to something shorter like `a`.
300300

301301
## Accessing the backend
302302

303-
Let's finish our example by fetching the exchange rates from the Yahoo Finance API.
303+
Let's finish our example by fetching the exchange rates from the [Fixer.io](http://fixer.io) exchange rate API.
304304
The following example shows how this is done with AngularJS:
305305

306306
<example name="guide-concepts-3" ng-app-included="true">
@@ -323,10 +323,6 @@ The following example shows how this is done with AngularJS:
323323
<file name="finance3.js">
324324
angular.module('finance3', [])
325325
.factory('currencyConverter', ['$http', function($http) {
326-
var YAHOO_FINANCE_URL_PATTERN =
327-
'//query.yahooapis.com/v1/public/yql?q=select * from ' +
328-
'yahoo.finance.xchange where pair in ("PAIRS")&format=json&' +
329-
'env=store://datatables.org/alltableswithkeys';
330326
var currencies = ['USD', 'EUR', 'CNY'];
331327
var usdToForeignRates = {};
332328

@@ -335,15 +331,10 @@ The following example shows how this is done with AngularJS:
335331
};
336332

337333
var refresh = function() {
338-
var url = YAHOO_FINANCE_URL_PATTERN.
339-
replace('PAIRS', 'USD' + currencies.join('","USD'));
334+
var url = 'https://api.fixer.io/latest?base=USD&symbols=' + currencies.join(",");
340335
return $http.get(url).then(function(response) {
341-
var newUsdToForeignRates = {};
342-
angular.forEach(response.data.query.results.rate, function(rate) {
343-
var currency = rate.id.substring(3,6);
344-
newUsdToForeignRates[currency] = window.parseFloat(rate.Rate);
345-
});
346-
usdToForeignRates = newUsdToForeignRates;
336+
usdToForeignRates = response.data.rates;
337+
usdToForeignRates['USD'] = 1;
347338
});
348339
};
349340

docs/content/guide/security.ngdoc

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ Protection from JSON Hijacking is provided if the server prefixes all JSON reque
100100
AngularJS will automatically strip the prefix before processing it as JSON.
101101
For more information please visit {@link $http#json-vulnerability-protection JSON Hijacking Protection}.
102102

103-
Bear in mind that calling `$http.jsonp`, like in [our Yahoo! finance example](https://docs.angularjs.org/guide/concepts#accessing-the-backend),
104-
gives the remote server (and, if the request is not secured, any Man-in-the-Middle attackers)
103+
Bear in mind that calling `$http.jsonp` gives the remote server (and, if the request is not secured, any Man-in-the-Middle attackers)
105104
instant remote code execution in your application: the result of these requests is handed off
106105
to the browser as regular `<script>` tag.
107106

0 commit comments

Comments
 (0)