1 parent
c6896ffa6a
commit
76bf364440
2 files changed
+9
-2
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/js-sdk": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(js-sdk): pass headers to auth.refresh()
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { HttpTypes } from "@medusajs/types"
|
import { HttpTypes } from "@medusajs/types"
|
||||||
import { Client } from "../client"
|
import { Client } from "../client"
|
||||||
import { Config } from "../types"
|
import { ClientHeaders, Config } from "../types"
|
||||||
|
|
||||||
export class Auth {
|
export class Auth {
|
||||||
private client: Client
|
private client: Client
|
||||||
@@ -214,6 +214,7 @@ export class Auth {
|
|||||||
* For an example of implementing third-party authentication, refer to the
|
* For an example of implementing third-party authentication, refer to the
|
||||||
* [Third-Party Login in Storefront](https://docs.medusajs.com/resources/storefront-development/customers/third-party-login) guide.
|
* [Third-Party Login in Storefront](https://docs.medusajs.com/resources/storefront-development/customers/third-party-login) guide.
|
||||||
*
|
*
|
||||||
|
* @param headers - Headers to pass in the request
|
||||||
*
|
*
|
||||||
* @returns The refreshed JWT authentication token.
|
* @returns The refreshed JWT authentication token.
|
||||||
*
|
*
|
||||||
@@ -225,11 +226,12 @@ export class Auth {
|
|||||||
* // all subsequent requests will use the token in the header
|
* // all subsequent requests will use the token in the header
|
||||||
* const { customer } = await sdk.store.customer.retrieve()
|
* const { customer } = await sdk.store.customer.retrieve()
|
||||||
*/
|
*/
|
||||||
refresh = async () => {
|
refresh = async (headers?: ClientHeaders) => {
|
||||||
const { token } = await this.client.fetch<{ token: string }>(
|
const { token } = await this.client.fetch<{ token: string }>(
|
||||||
"/auth/token/refresh",
|
"/auth/token/refresh",
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
headers,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user