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