How to use fetch-jsonp - 10 common examples

To help you get started, we’ve selected a few fetch-jsonp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imgcook-dsl / react-standard / code / index.jsx View on Github external
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() {
github jixianu / EasyFun / src / common / fetch.js View on Github external
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)
  );
}
github AleksandraKaminska / NavyPlayer / src / components / Albums / index.jsx View on Github external
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')
    }
  }
github heyui / heyui / src / components / demos / dataplugins / autocomplete5.vue View on Github external
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],
        };
      }));
    });
}
github heyui / heyui / src / components / demos / dataplugins / autocomplete9.vue View on Github external
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],
        };
      }));
    });
}
github ninjinkun / blog-feedback-app / src / models / fetchers / count-fetcher.ts View on Github external
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 };
    }
  );
}
github heyui / heyui / doc / components / demos / dataplugins / autocomplete7.vue View on Github external
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()
        };
      }));
    });
};
github vlsergey / WE-Framework / src / enhancements / viaf / ViafLookupDialog.js View on Github external
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 ],
          } ), {} );
github heyui / heyui / doc / js / config / heyui-config.js View on Github external
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);
github AleksandraKaminska / NavyPlayer / src / components / Similar / index.js View on Github external
    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])))

fetch-jsonp

Fetch JSONP like a boss using Fetch API

MIT
Latest version published 10 months ago

Package Health Score

64 / 100
Full package analysis

Popular fetch-jsonp functions