Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
jsonp_example() {
jsonp('https://assets.airbnb.com/frontend/search_results.js', { jsonpCallbackFunction: 'search_results', body: {} })
.then(response => response.json())
.then((data, error) => {
console.log('jsonp example: ', data, error);
return data;
})
.catch(e => {
console.log('error', e);
});
}
render() {
export function fetch_movie(opt) {
if (!opt) {
return false;
}
let REQUEST_PATH = `${config.SERVER_PATH}movie/${opt.type}`;
if (opt.type !== 'us_box') {
REQUEST_PATH += `?start=${opt.start}&count=${opt.count}`
}
const result = fetchJsonp(REQUEST_PATH, {
timeout: 3000,
});
return result.then(response=> {
return response.json();
}).catch(err=>
console.log('parsing failed', err)
);
}
showAlbumsTracks = e => {
e.preventDefault()
fetchJsonp(
`https://api.deezer.com/album/${e.currentTarget.dataset.id}?output=jsonp`
)
.then(resp => resp.json())
.then(album => store.dispatch(changeAlbumAction(album)))
if (this.songsRef.current.style.right !== '0em') {
this.songsRef.current.classList.remove('slidein')
this.songsRef.current.classList.add('slideout')
this.closeRef.current.classList.remove('buttonSlidein')
this.closeRef.current.classList.add('buttonSlideout')
}
}
const loadData = function (filter, callback) {
jsonp(`https://suggest.taobao.com/sug?code=utf-8&q=${filter}`)
.then(response => response.json())
.then((d) => {
callback(d.result.map((r) => {
return {
title: r[0],
key: r[1],
};
}));
});
}
const loadData = function (filter, callback) {
jsonp(`https://suggest.taobao.com/sug?code=utf-8&q=${filter}`)
.then(response => response.json())
.then((d) => {
callback(d.result.map((r) => {
return {
title: r[0],
key: r[1],
};
}));
});
}
export async function fetchHatenaBookmarkCounts(urls: string[]): Promise {
const apiUrl: string =
'https://b.hatena.ne.jp/entry.counts?' + urls.map((i: string) => `url=${encodeURIComponent(i)}`).join('&');
const response = await fetchJsonp(apiUrl);
const json = await response.json();
return Object.keys(json).map(
(url): CountResponse => {
return { url, count: json[url], type: CountType.HatenaBookmark };
}
);
}
const loadData = function (filter, callback) {
jsonp(`https://suggest.taobao.com/sug?code=utf-8&q=${filter}`)
.then(response => response.json())
.then((d) => {
callback(d.result.map((r) => {
return {
title: r[0],
key: r[1] + Math.random()
};
}));
});
};
doLookup( query : string ) {
const { queryScheduled } = this.state;
if ( query === queryScheduled ) return;
this.setState( { queryScheduled: query } );
if ( query === '' ) {
this.setState( { autoSuggestResult: [] } );
return;
}
this.setState( { queryState: 'SCHEDULED' } );
const url = '//viaf.org/viaf/AutoSuggest?query=' + encodeURIComponent( query );
fetchJsonp( url, {
jsonpCallback: 'callback',
} )
.then( response => response.json() )
.then( data => {
if ( this.state.queryScheduled !== query ) return;
const grouped = ( data.result || [] )
.filter( entity => typeof entity.viafid === 'string' )
.filter( entity => entity.viafid.trim() !== '' )
.reduce( ( acc, cur ) => ( {
...acc,
[ cur.viafid ]: acc[ cur.viafid ]
? [ ...acc[ cur.viafid ], cur ]
: [ cur ],
} ), {} );
const loadData = function (filter, callback) {
log('传递的参数', this.orgId);
jsonp(`https://suggest.taobao.com/sug?code=utf-8&q=${filter}`)
.then(response => response.json())
.then((d) => {
const result = d.result;
const data = [];
result.forEach((r) => {
data.push({
name: r[0],
id: r[1] + Math.random()
});
});
callback(data);
});
};
const menus = utils.toArray(dict.components, 'key', 'title').sort((a, b) => a.title > b.title ? 1 : -1);
fetchData = id => dispatch => fetchJsonp(`https://api.deezer.com/artist/${id}/top?output=jsonp`)
.then(response => response.json())
.then(({ data }) => data && dispatch(actions.changeTrackAction(data[0])))