看一个具体的例子:

https://github.com/SAP/spartacus/issues/11730

backport of #11744 to maintanance branch

As described in the Angular docs, a HttpResponse.url can be null or string. Therefore it should be checked in the AnonymousConsentsInterceptor before accessing it with startsWith.

By the way, now we export AnonymousConsentsInterceptor in the public API. There is no reason to hide it in the private API.

因为根据Angular文档,url 可以为null,因此在调用其方法之前,要先检查其是否可用。

关于TypeScript双问号的用法,请查看我这篇TypeScript里的空值合并运算符(双问号)用法.

在index.ts里,将AnonymousConsentsInterceptor使用export暴露给外部消费者即可。


关于 Spartacus API place order (下单) 的问题:

How are transactions handled in Spartacus? How many API requests are launched to create the order? If we use a WAF with Rate Limiting feature enabled, if one of the order related API request gets blocked is there any risk of payment not appearing to be created which could cause customer resending payment request, hence causing duplicated payments?

回复:

should be just one request in the end to place the order based on all the previously captured products, coupon, payment, addresses, shipping method, … which have more interaction bases APIs
so no worries, there should not be such an edge case as you explained, unless SPA is miss-customised

更多Jerry的原创文章,尽在:“汪子熙”:

SAP Spartacus public API的概念 - index.ts相关推荐

  1. SAP Spartacus的API暴露逻辑和index.ts的设计原理 - 什么是所谓的PUBLIC API

    以model UserSignUp为例: 从 @spatacus/core里导出: UserSignUp最终在文件misc.model.ts里定义: C:\Code\SPA\spartacus\pro ...

  2. 如何查看 ToggleStatusComponent 是否是 SAP Spartacus public API 一部分

    ToggleStatusComponent 通过ToggleStatusModule 暴露: 而 ToggleStatusModule 并未通过任何 module 暴露到index.ts中:

  3. SAP Commerce Cloud WCMS 里的 home 页面和 SAP Spartacus Page API 返回的数据比较

    You can only create new components in the WCMS Page View perspective. In the Live Edit perspective, ...

  4. 如何修改 SAP Spartacus CMS API 默认的 endpoint

    修改 Spartacus-configuration.module.ts 文件里的 occ 配置对象:例如在 cms 前缀后面加上1: import { NgModule } from '@angul ...

  5. SAP Spartacus避免不能向下兼容的breaking changes

    文档地址 以下这些都是引入了无法向下兼容的breaking changes,需要尽量避免: Changing the selector of a component, directive, or pi ...

  6. SAP Spartacus 服务器端渲染文件的 build 过程

    SAP Spartacus 根目录下有个 server.ts 文件.整个文件的入口是 run 函数: run 函数里,开启一个 服务器,监听在 4000 端口上: 服务器实例通过 app 函数返回: ...

  7. 如何自行找出 SAP Spartacus 查询用户信息的 API Service 类

    成功登录 SAP Spartacus 之后,在 Chrome 开发者工具 Network tab 里能看到一条读取用户信息的网络请求: https://20.83.184.244:9002/occ/v ...

  8. 一个简单的workaround - 如何使用SAP Spartacus中的private API

    技巧地址: https://stackoverflow.com/questions/66871919/how-to-use-private-api-of-the-spartacus-library 原 ...

  9. 在 SAP Spartacus 里如何调用 hybris 里实现的自定义 API

    需求:We have a custom API created in hybris and I need to use the data returned by that custom API in ...

最新文章

  1. NCEPU:线下组队学习周报(008)
  2. oracle 12c java 驱动,oracle12c驱动jar包
  3. linux 空闲等待时间TMOUT 反空闲设置 简介
  4. 分享JavaScript开发实战经验
  5. 操作系统基础:计算机作业管理知识笔记
  6. zepto源码研究 - ajax.js($.ajaxJSONP 的分析)
  7. 【youcans 的 OpenCV 例程200篇】117. 形态学操作之顶帽运算
  8. AI框架中图层IR的分析
  9. PCB芯片散热焊盘如何设计?
  10. js 生成26个英文字母
  11. 隐马尔可夫模型HMM学习笔记
  12. 不会查看GIT版本历史?快收藏这个工具
  13. iOS自定义相机实现拍照和连拍
  14. Linux配置文档 Samba
  15. 我们应该怎样看待经济危机
  16. 做亚马逊的工作,到底辛不辛苦?值得吗?
  17. Socket 网络协议 等
  18. C#安装Newtonsoft.Json并调用
  19. 字面量、对象字面量、函数字面量、函数定义
  20. [转帖]EventHandler部署工具

热门文章

  1. 【在线报表设计】提升报表外观的15个技巧
  2. 视频开发(即时通讯平台)
  3. 03 jquery easyui 之 easyLoader 加载器
  4. Apache详细介绍 - [ Apache v2.4.10 for Windows ]
  5. 将不确定变为确定~transactionscope何时提升为分布式事务?(sql2005数据库解决提升到MSDTC的办法)...
  6. ado.net 插入一条数据
  7. 如何使用新的邮件传输规则和邮件策略
  8. 中国豪华的政府大楼VS破学校
  9. 机器学习基础一(TP,TN,FP,FN等)
  10. linux系统中/etc/syslog.conf文件解读