-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathuse-custom-endpoint.tsx
More file actions
34 lines (28 loc) · 922 Bytes
/
use-custom-endpoint.tsx
File metadata and controls
34 lines (28 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import React from 'react'
import {useCustomQuery} from '@salesforce/commerce-sdk-react'
import Json from '../components/Json'
const UseCustomEndpoint = () => {
const {data, error} = useCustomQuery({
options: {
method: 'GET',
customApiPathParameters: {
apiVersion: 'v1',
endpointPath: 'test-hello-world',
apiName: 'hello-world'
}
},
rawResponse: false
})
if (error) {
return <h1 style={{color: 'red'}}>Something is wrong</h1>
}
return <Json data={data} />
}
UseCustomEndpoint.getTemplateName = () => 'UseCustomEndpoint'
export default UseCustomEndpoint