@@ -51,9 +51,9 @@ To use the Strapi Client in your project, install it as a dependency using your
5151
5252To start interacting with your Strapi back end, initialize the Strapi Client and set the base API URL:
5353
54- With Javascript, require the ` strapi ` function and create a client instance:
5554<Tabs groupId =" js-ts " >
5655<TabItem value =" js " label =" JavaScript " >
56+ With Javascript, require the ` strapi ` function and create a client instance:
5757
5858``` js
5959import { strapi } from ' @strapi/client' ;
@@ -62,9 +62,9 @@ const client = strapi({ baseURL: 'http://localhost:1337/api' });
6262```
6363</TabItem >
6464
65+ <TabItem value =" ts " label =" TypeScript " >
6566
6667With Typescript, import the ` strapi ` function and create a client instance with your Strapi API base URL:
67- <TabItem value =" ts " label =" TypeScript " >
6868
6969``` typescript
7070import { strapi } from ' @strapi/client' ;
@@ -74,18 +74,21 @@ const client = strapi({ baseURL: 'http://localhost:1337/api' });
7474</TabItem >
7575
7676
77- If you're using the Strapi Client in a browser environment, you can include it using a ` <script> ` tag.
7877<TabItem value =" browser " label =" Browser (UMD) " >
78+ If you're using the Strapi Client in a browser environment, you can include it using a ` <script> ` tag.
79+
7980``` js title="./src/api/[apiName]/routes/[routerName].ts (e.g './src/api/restaurant/routes/restaurant.ts')"
8081< script src= " https://cdn.jsdelivr.net/npm/@strapi/client" >< / script>
8182
8283< script>
8384 const client = strapi .strapi ({ baseURL: ' http://localhost:1337/api' });
8485< / script>
8586```
87+
8688</TabItem >
8789The ` baseURL ` must include the protocol (` http ` or ` https ` ). An invalid URL will throw an error ` StrapiInitializationError ` .
8890
91+ </Tabs >
8992
9093### Authentication
9194
0 commit comments