-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from vtex-apps/feature/shipping-options
Add shippingOptions to productSuggestions query
- Loading branch information
Showing
4 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const getSession = async () => { | ||
const headers = new Headers() | ||
|
||
headers.append('Content-Type', 'application/json') | ||
|
||
const requestOptions: RequestInit = { | ||
method: 'GET', | ||
headers, | ||
redirect: 'follow', | ||
} | ||
|
||
const session = await fetch( | ||
`${window.location.origin}/api/sessions?items=public.shippingOption`, | ||
requestOptions | ||
) | ||
|
||
const data = await session.json() | ||
|
||
if (!data?.namespaces?.public?.shippingOption?.value) { | ||
return null | ||
} | ||
|
||
return JSON.parse(data.namespaces.public.shippingOption.value) | ||
} | ||
|
||
export default getSession |