This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
docs($http): update YQL currency exchange API example #16137
Closed
Closed
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
264d25c
docs($http): update YQL currency exchange API example
andypotts 85292b4
docs($http): update reference to Yahoo Finance
andypotts b6e0bc7
docs($http): fix travis error
andypotts cc5ea8b
docs($http): remove non-existant jsonp example
andypotts 3ddd66b
docs($http): add links to fixer.io
andypotts ad33388
docs($http): update links to fixer.io
andypotts 3e90ea4
docs(*): fix grammatical error
andypotts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,7 +186,7 @@ Right now, the `InvoiceController` contains all logic of our example. When the a | |
is a good practice to move view-independent logic from the controller into a | ||
<a name="service">{@link services service}</a>, so it can be reused by other parts | ||
of the application as well. Later on, we could also change that service to load the exchange rates | ||
from the web, e.g. by calling the Yahoo Finance API, without changing the controller. | ||
from the web, e.g. by calling the Fixer.io exchange rate API, without changing the controller. | ||
|
||
Let's refactor our example and move the currency conversion into a service in another file: | ||
|
||
|
@@ -300,7 +300,7 @@ to something shorter like `a`. | |
|
||
## Accessing the backend | ||
|
||
Let's finish our example by fetching the exchange rates from the Yahoo Finance API. | ||
Let's finish our example by fetching the exchange rates from the Fixer.io exchange rate API. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make |
||
The following example shows how this is done with AngularJS: | ||
|
||
<example name="guide-concepts-3" ng-app-included="true"> | ||
|
@@ -323,10 +323,6 @@ The following example shows how this is done with AngularJS: | |
<file name="finance3.js"> | ||
angular.module('finance3', []) | ||
.factory('currencyConverter', ['$http', function($http) { | ||
var YAHOO_FINANCE_URL_PATTERN = | ||
'//query.yahooapis.com/v1/public/yql?q=select * from ' + | ||
'yahoo.finance.xchange where pair in ("PAIRS")&format=json&' + | ||
'env=store://datatables.org/alltableswithkeys'; | ||
var currencies = ['USD', 'EUR', 'CNY']; | ||
var usdToForeignRates = {}; | ||
|
||
|
@@ -335,15 +331,10 @@ The following example shows how this is done with AngularJS: | |
}; | ||
|
||
var refresh = function() { | ||
var url = YAHOO_FINANCE_URL_PATTERN. | ||
replace('PAIRS', 'USD' + currencies.join('","USD')); | ||
var url = 'https://api.fixer.io/latest?base=USD&symbols=' + currencies.join(","); | ||
return $http.get(url).then(function(response) { | ||
var newUsdToForeignRates = {}; | ||
angular.forEach(response.data.query.results.rate, function(rate) { | ||
var currency = rate.id.substring(3,6); | ||
newUsdToForeignRates[currency] = window.parseFloat(rate.Rate); | ||
}); | ||
usdToForeignRates = newUsdToForeignRates; | ||
usdToForeignRates = response.data.rates; | ||
usdToForeignRates['USD'] = 1; | ||
}); | ||
}; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,7 +100,7 @@ Protection from JSON Hijacking is provided if the server prefixes all JSON reque | |
AngularJS will automatically strip the prefix before processing it as JSON. | ||
For more information please visit {@link $http#json-vulnerability-protection JSON Hijacking Protection}. | ||
|
||
Bear in mind that calling `$http.jsonp`, like in [our Yahoo! finance example](https://docs.angularjs.org/guide/concepts#accessing-the-backend), | ||
Bear in mind that calling `$http.jsonp`, like in [our currency exchange example](https://docs.angularjs.org/guide/concepts#accessing-the-backend), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, this |
||
gives the remote server (and, if the request is not secured, any Man-in-the-Middle attackers) | ||
instant remote code execution in your application: the result of these requests is handed off | ||
to the browser as regular `<script>` tag. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make
Fixer.io
a link.