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


TypeScript mithril.request函數代碼示例

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


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

示例1: updateTags

export function updateTags(deviceId, tags): Promise<void> {
  return m.request({
    method: "POST",
    url: `/api/devices/${encodeURIComponent(deviceId)}/tags`,
    data: tags
  });
}
開發者ID:zaidka,項目名稱:genieacs,代碼行數:7,代碼來源:store.ts

示例2: makeRequest

  private static makeRequest(url: string,
                             method: string,
                             apiVersion?: ApiVersion,
                             options?: Partial<RequestOptions>): Promise<ApiResult<string>> {
    const headers = this.buildHeaders(method, apiVersion, options);

    let payload: any;
    if (options && options.payload) {
      payload = options.payload;
    }

    return m.request<XMLHttpRequest>({
                                       url,
                                       method,
                                       headers,
                                       data: payload,
                                       extract: _.identity,
                                       deserialize: _.identity,
                                       config: (xhr) => {
                                         if (options && options.xhrHandle) {
                                           options.xhrHandle(xhr);
                                         }
                                       }
                                     }).then((xhr: XMLHttpRequest) => {
      return ApiResult.from(xhr);
    }).catch((reason) => {
      const unknownError = "There was an unknown error performing the operation.";
      try {
        return ApiResult.error(reason.responseText, JSON.parse(reason.message).message || unknownError, reason.status);
      } catch {
        return ApiResult.error(reason.responseText, unknownError, reason.status);
      }
    });
  }
開發者ID:GaneshSPatil,項目名稱:gocd,代碼行數:34,代碼來源:api_request_builder.ts

示例3: return

 return (dispatch, getState) => {
     dispatch(requestCode(uri));
     request(uri, { deserialize: x => x })
         .then(code => {
             dispatch(recieveCode(uri, code));
         });
 }
開發者ID:phincallahan,項目名稱:personal-website,代碼行數:7,代碼來源:index.ts

示例4: queryConfig

export function queryConfig(pattern = "%"): Promise<any[]> {
  const filter = stringify(["LIKE", ["PARAM", "_id"], pattern]);
  return m.request({
    method: "GET",
    url: `api/config/?${m.buildQueryString({ filter: filter })}`,
    background: true
  });
}
開發者ID:zaidka,項目名稱:genieacs,代碼行數:8,代碼來源:store.ts

示例5: logIn

export function logIn(username, password): Promise<void> {
  return m.request({
    method: "POST",
    url: "/login",
    background: true,
    data: { username, password }
  });
}
開發者ID:zaidka,項目名稱:genieacs,代碼行數:8,代碼來源:store.ts

示例6: putResource

export function putResource(resourceType, id, object): Promise<void> {
  for (const k in object) if (object[k] === undefined) object[k] = null;

  return m.request({
    method: "PUT",
    url: `/api/${resourceType}/${encodeURIComponent(id)}`,
    data: object
  });
}
開發者ID:zaidka,項目名稱:genieacs,代碼行數:9,代碼來源:store.ts

示例7: requestMesssge

 public requestMesssge() {
     return m.request({
         method: "GET",
         url: "/api/message",
         initialValue: null
     })
         .then((data) => {
             return new SampleMessage(data.value);
         });
 }
開發者ID:grimrose,項目名稱:JJUG-CCC-2016-Spring,代碼行數:10,代碼來源:sample.ts

示例8: changePassword

export function changePassword(
  username,
  newPassword,
  authPassword?
): Promise<void> {
  const data = { newPassword };
  if (authPassword) data["authPassword"] = authPassword;
  return m.request({
    method: "PUT",
    url: `/api/users/${username}/password`,
    background: true,
    data
  });
}
開發者ID:zaidka,項目名稱:genieacs,代碼行數:14,代碼來源:store.ts

示例9: resourceExists

export function resourceExists(resource, id): Promise<number> {
  const param = resource === "devices" ? "DeviceID.ID" : "_id";
  const filter = ["=", ["PARAM", param], id];
  return m.request({
    method: "HEAD",
    url:
      `/api/${resource}/?` +
      m.buildQueryString({
        filter: memoizedStringify(filter)
      }),
    extract: xhr => +xhr.getResponseHeader("x-total-count"),
    background: true
  });
}
開發者ID:zaidka,項目名稱:genieacs,代碼行數:14,代碼來源:store.ts

示例10: FormData

	const upload = (e: Event) => {
		const file = ((e.target as HTMLInputElement).files as FileList)[0];
		const data = new FormData();
		data.append("myfile", file);
		m.request({
			method: "POST",
			url: "/api/v1/upload",
			data,
			config: xhr => {
				xhr.addEventListener("progress", e => {
					progress = e.loaded / e.total;
					m.redraw(); // tell Mithril that data changed and a re-render is needed
				});
			}
		});
	};
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:16,代碼來源:test-api.ts


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