mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
creating util function for requesting auth from the rbac server
This commit is contained in:
parent
137f57d5af
commit
ad83649cb8
27
src/utils/rbac.ts
Normal file
27
src/utils/rbac.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import fetch from 'cross-fetch'
|
||||
|
||||
export async function rebacRequest(
|
||||
component: string,
|
||||
eventType: string,
|
||||
token: string
|
||||
): Promise<Response> {
|
||||
const data = {
|
||||
component,
|
||||
eventType,
|
||||
credentials: {
|
||||
token
|
||||
}
|
||||
}
|
||||
try {
|
||||
const response = await fetch(process.env.RBAC_URL, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
return await response.json()
|
||||
} catch (error) {
|
||||
console.error('Error parsing json: ' + error.message)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user