當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fetch.fetch函數代碼示例

本文整理匯總了TypeScript中domain-task/fetch.fetch函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fetch函數的具體用法?TypeScript fetch怎麽用?TypeScript fetch使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了fetch函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: fetch

 requestGenresList: (): ActionCreator => (dispatch, getState) => {
     if (!getState().genreList.isLoaded) {
         fetch('/api/genres')
             .then(results => results.json())
             .then(genres => dispatch(new ReceiveGenresList(genres)));
     }
 }
開發者ID:Naveen-Bhat,項目名稱:NodeServices,代碼行數:7,代碼來源:GenreList.ts

示例2: fetch

    userList: (): ActionCreator => (dispatch, getState) => {
            fetch(`/users`,{ method: 'GET'})
                .then(response => response.json())
                .then((data: any) => {
                    dispatch(new UserList(data.data));
                });

            dispatch(new UserLoad());
    },
開發者ID:AaronJin2013,項目名稱:react-frame-demo,代碼行數:9,代碼來源:index.ts

示例3: fetch

    requestFeaturedAlbums: (): ActionCreator => (dispatch, getState) => {
        if (!getState().featuredAlbums.isLoaded) {
            fetch('/api/albums/mostPopular')
                .then(results => results.json())
                .then(albums => dispatch(new ReceiveFeaturedAlbums(albums)));

            return dispatch(new RequestFeaturedAlbums());
        }
    }
開發者ID:An0564,項目名稱:JavaScriptServices,代碼行數:9,代碼來源:FeaturedAlbums.ts

示例4: getState

 vote: (pollId: number, choiceId: number): ActionCreator => (dispatch, getState) => {
   let bearer = getState().auth.token;
   fetch(`/api/polls/${pollId}/choices/${choiceId}`, {
     method: 'post',
     headers: {
       'Authorization': `Bearer ${bearer}`,
     }
   });
 }
開發者ID:dmayala,項目名稱:BallotboxCore,代碼行數:9,代碼來源:Polls.ts

示例5: dispatch

    userItem: (UUID,callback): ActionCreator => (dispatch, getState) => {

        dispatch(new UserItem(UserModel.Model));
        fetch(`/users/`+UUID,{ method: 'GET'})
            .then(response => response.json())
            .then((data: any) => {
                dispatch(new UserItem(data.data));
                callback();
            });

        dispatch(new UserLoad());
    },
開發者ID:AaronJin2013,項目名稱:react-frame-demo,代碼行數:12,代碼來源:index.ts

示例6: fetch

    requestWeatherForecasts: (startDateIndex: number): ActionCreator => (dispatch, getState) => {
        // Only load data if it's something we don't already have (and are not already loading)
        if (startDateIndex !== getState().weatherForecasts.startDateIndex) {
            fetch(`/api/SampleData/WeatherForecasts?startDateIndex=${ startDateIndex }`)
                .then(response => response.json())
                .then((data: WeatherForecast[]) => {
                    dispatch(new ReceiveWeatherForecasts(startDateIndex, data));
                });

            dispatch(new RequestWeatherForecasts(startDateIndex));
        }
    }
開發者ID:An0564,項目名稱:JavaScriptServices,代碼行數:12,代碼來源:WeatherForecasts.ts

示例7: fetch

 requestAlbumDetails: (albumId: number): ActionCreator => (dispatch, getState) => {
     // Only load if it's not already loaded (or currently being loaded)
     if (albumId !== getState().albumDetails.requestedAlbumId) {
         fetch(`/api/albums/${ albumId }`)
             .then(results => results.json())
             .then(album => {
                 // Only replace state if it's still the most recent request
                 if (albumId === getState().albumDetails.requestedAlbumId) {
                     dispatch(new ReceiveAlbumDetails(album));
                 }
             });
         
         dispatch(new RequestAlbumDetails(albumId));
     }
 }
開發者ID:Naveen-Bhat,項目名稱:NodeServices,代碼行數:15,代碼來源:AlbumDetails.ts


注:本文中的domain-task/fetch.fetch函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。