当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript qs.stringify函数代码示例

本文整理汇总了TypeScript中qs.stringify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stringify函数的具体用法?TypeScript stringify怎么用?TypeScript stringify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了stringify函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: jsonp

export const getInstagramPhotos = (userId: string, accessToken: string): Promise<Response> => {
  const params = qs.stringify({
    access_token: accessToken,
    count: 10,
  })
  const url = `https://api.instagram.com/v1/users/${userId}/media/recent/?${params}`

  const key = `grams_${userId}_${md5(params)}`
  const result = cache.get(key)
  if (cache.get(key)) {
    return Promise.resolve(Ok(result))
  }

  return jsonp(url)
    .then(response => response.json())
    .then((response: Instagram.Response) => {
      if (response.meta.code === 400) {
        return Err({
          message: response.meta.error_message,
          info: `URL: ${url}`,
        })
      }
      cache.set(key, response.data, 22)
      return Ok(response.data)
    })
    .catch(err => Err(err))
}
开发者ID:harrygr,项目名称:op-website,代码行数:27,代码来源:instagram.ts

示例2: postForm

export function postForm(url, data, onError) {
  const d = data ? _.cloneDeep(data) : {};
  d.lang = getLocale();

  const req = post(url, qs.stringify(d));
  return handleRequest(req, onError);
}
开发者ID:xlsdg,项目名称:umi-dva-antd-typescript-starter,代码行数:7,代码来源:request.ts

示例3: serializeBrowserState

export function serializeBrowserState(paths: PathConfigs<BrowserState>, s: BrowserState): Partial<Location> {
  const path = browserStateToPathConfig(paths, s);
  const pathState = path.pick(s);
  const pathname = `/${path.serialize(mapValues(pathState, encodeURIComponent))}`;
  const search = `?${qs.stringify(omit(s, Object.keys(pathState)))}`; // will encode URI by default
  return { pathname, search };
}
开发者ID:buildo,项目名称:state,代码行数:7,代码来源:browser.ts

示例4: iteratePerusteet

export async function* iteratePerusteet(params: any = {}) {
    let sivu = 0;

    params = { ...defaultParams, ...params };

    while (true) {
        const res = await axios.get(PerusteEndpoint, {
            params: { ...params, sivu, sivukoko: 100 },
            paramsSerializer(params) {
                return qs.stringify(params, { arrayFormat: "repeat" });
            }
        });

        if (_.isEmpty(res.data.data)) {
            return;
        }

        console.log(`Got page ${sivu}`, _.size(res.data.data));
        console.log(res.data.sivu, res.data.kokonaismäärä, res.data.sivukoko);
        sivu += 1;

        for (const data of res.data.data) {
            yield data as any;
        }
    }
}
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:26,代码来源:lib.ts

示例5: urlJoin

export const productListUrl = (params?: ProductListQueryParams): string => {
  if (params === undefined) {
    return productListPath;
  } else {
    return urlJoin(productListPath, "?" + stringifyQs(params));
  }
};
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:7,代码来源:urls.ts

示例6: serialize

/*
 * Serialize relevant portions of the state tree into a string
 */
export default function serialize(state: State): string {
  const {
    lar: { filters, points: { scaleFactor } },
    mapbox: { choropleth, features },
    viewport: { latitude, longitude, zoom },
  } = state;
  const { year } = filters;
  const filterValues: any = {};
  Object.keys(filters)
    .filter(key => key !== "year" && filters[key].size)
    .forEach(key => {
      filterValues[key] = filters[key].join(",");
    });
  return qs.stringify(
    {
      ...filterValues,
      choropleth,
      latitude,
      longitude,
      scaleFactor,
      year,
      zoom,
      features: features.join(","),
    },
    { encode: false, skipNulls: true },
  );
}
开发者ID:cmc333333,项目名称:mapusaurus,代码行数:30,代码来源:serialize.ts

示例7: makeSearchLink

function makeSearchLink(query: string): string {
    const url = "https://soundcloud.com/search/sounds";
    const params = qs.stringify({
        q: query,
    });

    return `${url}?${params}`;
}
开发者ID:endway,项目名称:songSearchBot,代码行数:8,代码来源:soundcloud.ts

示例8: urlJoin

export const orderListUrl = (params?: OrderListUrlQueryParams): string => {
  const orderList = orderListPath;
  if (params === undefined) {
    return orderList;
  } else {
    return urlJoin(orderList, "?" + stringifyQs(params));
  }
};
开发者ID:mirumee,项目名称:saleor,代码行数:8,代码来源:urls.ts

示例9: productImagePath

export const productImageUrl = (
  productId: string,
  imageId: string,
  params?: ProductImageUrlQueryParams
) =>
  productImagePath(encodeURIComponent(productId), encodeURIComponent(imageId)) +
  "?" +
  stringifyQs(params);
开发者ID:mirumee,项目名称:saleor,代码行数:8,代码来源:urls.ts

示例10: replaceLimitAndOffsetInUri

export function replaceLimitAndOffsetInUri(oldUri: string, limit: number[], offset: number[]): string {
    const [uriPart, queryPart] = oldUri.split(/\?(.+)/);
    const query = {
        ...qs.parse(queryPart),
        limit: limit.join(','),
        offset: offset.join(',')
    };

    return uriPart + qs.stringify(query, { addQueryPrefix: true });
}
开发者ID:gooddata,项目名称:gooddata-js,代码行数:10,代码来源:execute-afm.ts


注:本文中的qs.stringify函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。