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


TypeScript domain-task.fetch函數代碼示例

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


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

示例1: getList

export function getList() {
  let fetchTask = fetch("/api/list")
    .then(r => r.json())
    .then(data => (store.list = data))
  addTask(fetchTask)
  return fetchTask
}
開發者ID:tpetrina,項目名稱:presentations,代碼行數:7,代碼來源:api.ts

示例2: fetch

    requestToArray: (): AppThunkAction<KnownAction> => (dispatch, getState) => {
        let fetchTask = fetch(`/api/Stack/ToArray`)
            .then(response => response.json() as Promise<Item[]>)
            .then(data => dispatch({ type: 'RECEIVE_TOARRAY', items: data }));

        addTask(fetchTask); // Ensure server-side prerendering waits for this to complete
        dispatch({ type: 'REQUEST_TOARRAY' });
    }
開發者ID:hlaueriksson,項目名稱:ConductOfCode,代碼行數:8,代碼來源:Stack.ts

示例3: fetch

 requestStudents: (): AppThunkAction<KnownAction> => (dispatch, getState) => {
     let fetchTask = fetch(`api/Students`)
         .then(response => response.json() as Promise<Student[]>)
         .then(data => {
             dispatch({ type: 'RECIVE_STUDENTS', students: data });
         });
     addTask(fetchTask);
     dispatch({ type: 'REQUEST_STUDENTS' });
 }
開發者ID:PaulTmatik,項目名稱:pedcollege_template,代碼行數:9,代碼來源:Students.ts

示例4: fetch

 requestWeather: (location: string): ActionCreator => (dispatch, getState) => {
     if (location !== getState().weather.location) {
         let fetchData = fetch(`/api/Weather/${location}`)
             .then(response => response.json())
             .then((data: Weather) => {
                 dispatch(new RecieveWeather(data));
             })
             .catch((error) => {
                 browserHistory.push('/error');
             });  
         dispatch(new RequestWeather(location));
     }
 },
開發者ID:mikeyjones,項目名稱:WeatherTest,代碼行數:13,代碼來源:Weather.ts

示例5: fetch

    requestWeatherForecasts: (startDateIndex: number): AppThunkAction<KnownAction> => (dispatch, getState) => {
        // Only load data if it's something we don't already have (and are not already loading)
        if (startDateIndex !== getState().weatherForecasts.startDateIndex) {
            let fetchTask = fetch(`api/SampleData/WeatherForecasts?startDateIndex=${ startDateIndex }`)
                .then(response => response.json() as Promise<WeatherForecast[]>)
                .then(data => {
                    dispatch({ type: 'RECEIVE_WEATHER_FORECASTS', startDateIndex: startDateIndex, forecasts: data });
                });

            addTask(fetchTask); // Ensure server-side prerendering waits for this to complete
            dispatch({ type: 'REQUEST_WEATHER_FORECASTS', startDateIndex: startDateIndex });
        }
    }
開發者ID:OpenTouryoProject,項目名稱:SampleProgram,代碼行數:13,代碼來源:WeatherForecasts.ts

示例6: fetch

    requestCompanies: (userId: number): AppThunkAction<KnownAction> => (dispatch, getState) => {
        // Only load data if it's something we don't already have (and are not already loading)
        if (userId !== getState().companies.userId) {
            let fetchTask = fetch(`http://localhost:5001/api/company?userId=${userId}`)
                .then(response => response.json() as Promise<Company[]>)
                .then(data => {
                    dispatch({ type: 'RECEIVE_COMPANIES', userId: userId, companies: data });
                });

            addTask(fetchTask); // Ensure server-side prerendering waits for this to complete
            dispatch({ type: 'REQUEST_COMPANIES', userId: userId });
        }
    },
開發者ID:alexanderchoban,項目名稱:OpenSBIS,代碼行數:13,代碼來源:Companies.ts


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