• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript query-string.stringify函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: request

 /**
  * Send a request
  * @param type
  * @param endpoint
  * @param options
  * @param callback
  * @private
  */
 private async request(
   type: string,
   endpoint: string,
   options: any = {},
   callback?: (err?: any, data?: any) => void
 ): Promise<any> {
   try {
     if (isFunction(options)) {
       callback = options;
       options = {};
     }
     let stringify = true;
     const headers = {};
     let uri = `${this.apiUrl}${endpoint}`;
     if (this.config.accessToken) {
       options.access_token = this.config.accessToken;
     }
     if (options.accessToken) {
       options.access_token = options.accessToken;
       delete options.accessToken;
     }
     if (options.uriAbsolute) {
       uri = `${this.baseApiUrl}/${endpoint}`;
       delete options.uriAbsolute;
     }
     if (type === 'GET' || type === 'DELETE') {
       uri += `?${queryString.stringify(options)}`;
       options = null;
     } else if (type === 'POST') {
       headers['Content-Type'] =
         'application/x-www-form-urlencoded;charset=UTF-8';
       options = queryString.stringify(options);
       stringify = false;
     }
     const response = await fetch(uri, {
       method: type,
       body: options && stringify ? JSON.stringify(options) : options || null,
       headers,
     });
     const json = await response.json();
     if (!response.ok) {
       throw json;
     }
     if (isFunction(callback)) {
       callback(null, json);
     }
     return json;
   } catch (err) {
     const error = err.error || err;
     if (isFunction(callback)) {
       return callback(error);
     }
     throw error;
   }
 }
开发者ID:pradel,项目名称:node-instagram,代码行数:63,代码来源:index.ts


示例2: async

export const fetchPortfolioItems: PortfolioThunkActionCreator<Portfolio[]> = (
  params: PortfolioRequestParams,
) => {
  const {
    requestedPageNumber,
    pageSize,
    categories = [],
    tags = [],
    searchTerm,
  } = params;

  const query = queryString.stringify({
    requestedPageNumber,
    pageSize,
    categores: categories.join(','),
    tags: tags.join(','),
    searchTerm,
  });

  return async (dispatch, getState, api) => {
    const action = await composeActionFromAsyncRequest(
      types.FETCH_PORTFOLIO_ITEMS,
    )(api.get(`/portfolio?${query}`));
    dispatch(action);
  };
};
开发者ID:ericmasiello,项目名称:synbydesign,代码行数:26,代码来源:actions.ts


示例3: Promise

        return new Promise((resolve, reject) => {
            const url = queryObject ? `/files?${QueryString.stringify(queryObject)}` : '/files';

            this.oauth.authenticatedRequest(url, {
                method: 'GET',
            }).then(body => {
                let table = new Table({
                    chars: { 'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },
                    colWidths: [26, 30, 15, 10],
                    head: ['Id', 'Name', 'Size', 'Accesses'],
                });

                for (let file of body) {
                    file.size = file.size ? filesize(file.size) : 'None';
                    table.push([
                        file._id, file.name, file.size, file.accesses || 'none',
                    ]);
                }

                console.log(table.toString());
                resolve();
            }, err => {
                reject(err);
            });
        });
开发者ID:victorjacobs,项目名称:chullo-client,代码行数:25,代码来源:client.ts


示例4: getLaunchEditorUrl

function getLaunchEditorUrl(errorLocation: ErrorOverlay.ErrorLocation) {
  return `${LAUNCH_EDITOR_ENDPOINT}?${qs.stringify({
    filePath: errorLocation.fileName,
    line: errorLocation.lineNumber || 1,
    column: errorLocation.colNumber || 1
  })}`;
}
开发者ID:skidding,项目名称:cosmos,代码行数:7,代码来源:reactErrorOverlay.ts


示例5: Headers

export const gatherWithQuery = async <Q, A>(opts: IGatherQueryOptions<Q>): Promise<IGatherResult<A>> => {
    const query =
        typeof opts.query === "undefined" ? null : queryString.stringify(opts.query, { arrayFormat: "index" });
    const method = typeof opts.method === "undefined" ? "GET" : opts.method;
    const headers: Headers = (() => {
        if (typeof opts.headers === "undefined") {
            return new Headers({ "content-type": "application/json" });
        }

        return opts.headers;
    })();

    const url = (() => {
        if (query === null) {
            return opts.url;
        }

        return `${opts.url}?${query}`;
    })();

    const response = await fetch(url, {
        headers,
        method,
    });

    return handleResponse(response);
};
开发者ID:ihsw,项目名称:sotah-client,代码行数:27,代码来源:index.ts


示例6:

const ebayResultUrlForKeywords = (keywords: string) =>
  `${
    process.env.EBAY_API_SERVER
  }/services/search/FindingService/v1?${queryString.stringify({
    ...EBAY_FIND_SETTINGS,
    keywords
  })}`
开发者ID:crooked-ventures,项目名称:literally.deals,代码行数:7,代码来源:random-ebay-result.ts


示例7: serialize

 /**
  * serialize track states to query string
  */
 public serialize():string {
   var params = [];
   for (let key in this.tracks) {
     let param = this.tracks[key].join(',');
     params[key] = param || undefined;
   }
   return querystring.stringify(params);
 }
开发者ID:c9s,项目名称:qama,代码行数:11,代码来源:EntryStore.ts


示例8: createAuthUrl

export function createAuthUrl(input: types.AuthenticateInput): string {
    return ENDPOINT + 'v3/auth/auth?' + querystring.stringify({
        client_id: input.client_id,
        redirect_uri: input.redirect_uri,
        response_type: input.response_type,
        scope: input.scope
    });
}
开发者ID:emonkak,项目名称:feedpon,代码行数:8,代码来源:api.ts


示例9: return

 return (key: string, value?) => {
   if (value === "") {
     delete querystring[key];
   } else {
     querystring[key] = value || key;
   }
   history.replace("?" + stringifyQs(querystring));
 };
开发者ID:p2p-ms,项目名称:front,代码行数:8,代码来源:utils.ts


示例10: stringify

export const queryString = (props: Array<string>) => (obj: Properties): Properties => {
  const qs = stringify(props.reduce((res, key) => {
    res[key] = obj[key];
    return res;
  }, {}));

  return Object.assign({}, obj, {
    queryString: qs.length > 0 ? '?' + qs : ''
  });
}
开发者ID:MikeRyan52,项目名称:typesafe-urls,代码行数:10,代码来源:query-string.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript querystring.escape函数代码示例发布时间:2022-05-25
下一篇:
TypeScript query-string.parse函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap