@@ -51,41 +51,48 @@ 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 " >
5756
57+ With Javascript, require the ` strapi ` function and create a client instance:
58+
5859``` js
5960import { strapi } from ' @strapi/client' ;
6061
6162const client = strapi ({ baseURL: ' http://localhost:1337/api' });
6263```
64+
6365</TabItem >
6466
67+ <TabItem value =" ts " label =" TypeScript " >
6568
6669With Typescript, import the ` strapi ` function and create a client instance with your Strapi API base URL:
67- <TabItem value =" ts " label =" TypeScript " >
6870
6971``` typescript
7072import { strapi } from ' @strapi/client' ;
7173
7274const client = strapi ({ baseURL: ' http://localhost:1337/api' });
7375```
76+
7477</TabItem >
7578
79+ <TabItem value =" browser " label =" Browser (UMD) " >
7680
7781If you're using the Strapi Client in a browser environment, you can include it using a ` <script> ` tag.
78- < TabItem value = " browser " label = " Browser (UMD) " >
82+
7983``` js title="./src/api/[apiName]/routes/[routerName].ts (e.g './src/api/restaurant/routes/restaurant.ts')"
8084< script src= " https://cdn.jsdelivr.net/npm/@strapi/client" >< / script>
8185
8286< script>
8387 const client = strapi .strapi ({ baseURL: ' http://localhost:1337/api' });
8488< / script>
8589```
90+
8691</TabItem >
87- The ` baseURL ` must include the protocol (` http ` or ` https ` ). An invalid URL will throw an error ` StrapiInitializationError ` .
8892
93+ </Tabs >
94+
95+ The ` baseURL ` must include the protocol (` http ` or ` https ` ). An invalid URL will throw an error ` StrapiInitializationError ` .
8996
9097### Authentication
9198
0 commit comments