當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。