From 6f3aaa003590f6560a3ac8e2877e6849c5dd6f2d Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 24 Oct 2021 06:36:49 -0700 Subject: [PATCH] Update to sjs-dom 2.0.0 (#354) Co-authored-by: Adam Fraser --- build.sbt | 2 +- jshttp/src/main/scala/zio/logging/js/HTTPLogger.scala | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 1945b59f..79a44de6 100644 --- a/build.sbt +++ b/build.sbt @@ -119,7 +119,7 @@ lazy val jshttp = project .settings(stdSettings("zio-logging-jshttp")) .settings( libraryDependencies ++= Seq( - "org.scala-js" %%% "scalajs-dom" % "1.2.0" + "org.scala-js" %%% "scalajs-dom" % "2.0.0" ) ) diff --git a/jshttp/src/main/scala/zio/logging/js/HTTPLogger.scala b/jshttp/src/main/scala/zio/logging/js/HTTPLogger.scala index 68a974f2..83c7bb6b 100644 --- a/jshttp/src/main/scala/zio/logging/js/HTTPLogger.scala +++ b/jshttp/src/main/scala/zio/logging/js/HTTPLogger.scala @@ -1,6 +1,6 @@ package zio.logging.js -import org.scalajs.dom.ext.Ajax +import org.scalajs.dom.{ Fetch, HttpMethod, RequestInit } import zio.clock.{ Clock, currentDateTime } import zio.logging.{ LogAnnotation, LogAppender, LogContext, LogFormat, LogLevel, Logging } import zio.{ ZIO, ZLayer } @@ -13,7 +13,14 @@ import scala.scalajs.js.JSON object HTTPLogger { private def sendMessage(url: String, msg: js.Object) = - Ajax.post(url, JSON.stringify(msg), headers = Map("Content-Type" -> "application/json")) + Fetch.fetch( + url, + new RequestInit { + method = HttpMethod.POST + body = JSON.stringify(msg) + headers = js.Dictionary("Content-Type" -> "application/json") + } + ) /** * Parameters: