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: