Skip to content

Commit 3291813

Browse files
NataliaTepluhinayyx990803
authored andcommitted
fix: fixed Wikipedia example to use RxJS ajax (#102)
1 parent dcd0ab8 commit 3291813

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

example/wiki-search.html

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<script src="https://unpkg.com/jquery"></script>
21
<script src="https://unpkg.com/rxjs/bundles/rxjs.umd.js"></script>
32
<script src="https://unpkg.com/vue/dist/vue.js"></script>
43
<script src="../dist/vue-rx.js"></script>
@@ -23,18 +22,14 @@ <h1>{{ results.term }}</h1>
2322

2423
<script>
2524
const { from } = rxjs
25+
const { ajax } = rxjs.ajax
2626
const { pluck, filter, debounceTime, distinctUntilChanged, switchMap, map } = rxjs.operators
2727

28+
const baseUrl =
29+
'https://en.wikipedia.org/w/api.php?action=opensearch&format=json&origin=*'
30+
2831
function fetchTerm (term) {
29-
return from($.ajax({
30-
url: 'http://en.wikipedia.org/w/api.php',
31-
dataType: 'jsonp',
32-
data: {
33-
action: 'opensearch',
34-
format: 'json',
35-
search: term
36-
}
37-
}).promise())
32+
return ajax.getJSON(`${baseUrl}&search=${term}`)
3833
}
3934

4035
function formatResult (res) {

0 commit comments

Comments
 (0)