post-payload.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports._postPayload = _postPayload;
  6. var _asyncRetry = _interopRequireDefault(require("next/dist/compiled/async-retry"));
  7. var _nodeFetch = _interopRequireDefault(require("next/dist/compiled/node-fetch"));
  8. function _interopRequireDefault(obj) {
  9. return obj && obj.__esModule ? obj : {
  10. default: obj
  11. };
  12. }
  13. function _postPayload(endpoint, body) {
  14. return (0, _asyncRetry).default(()=>(0, _nodeFetch).default(endpoint, {
  15. method: "POST",
  16. body: JSON.stringify(body),
  17. headers: {
  18. "content-type": "application/json"
  19. },
  20. timeout: 5000
  21. }).then((res)=>{
  22. if (!res.ok) {
  23. const err = new Error(res.statusText);
  24. err.response = res;
  25. throw err;
  26. }
  27. }), {
  28. minTimeout: 500,
  29. retries: 1,
  30. factor: 1
  31. }).catch(()=>{
  32. // We swallow errors when telemetry cannot be sent
  33. })// Ensure promise is voided
  34. .then(()=>{}, ()=>{});
  35. }
  36. //# sourceMappingURL=post-payload.js.map