<@U04UQ68083H> How to migrate from `@ory/client` t...
# ory-copilot
r
@chilly-king-10285 How to migrate from
@ory/client
to
@ory/client-fetch
. Basically from axios to fetch.
c
A message from kapa.ai
Hmm, I don't know enough to give you a confident answer yet. The provided knowledge sources do not contain specific information on migrating from
@ory/client
(which uses axios) to
@ory/client-fetch
(which uses fetch). However, I can provide some general guidance based on the usage of
@ory/client
in the knowledge sources. In the
@ory/client
, you typically create an instance of
FrontendApi
with a
Configuration
object. The
Configuration
object includes a
basePath
and
baseOptions
with
withCredentials: true
to ensure cookies are sent with CORS requests. Here's an example:
Copy code
javascript import { FrontendApi, Configuration } from "@ory/client"  const ory = new FrontendApi(   new Configuration({     basePath,     baseOptions: {       withCredentials: true,     },   }), )
When making requests, you can use methods like
ory.toSession()
to fetch the session directly from Ory. If you're migrating to fetch, you'll need to ensure that you're still sending cookies with your requests. In fetch, this is done by including
credentials: 'include'
in the options for your fetch request:
Copy code
javascript fetch("<https://ory.your-custom-domain.com/>", {     credentials: "include",   })
Please refer to the official documentation or the specific
@ory/client-fetch
library documentation for more detailed instructions on how to migrate.