当前位置: 首页>>代码示例>>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;未经允许,请勿转载。