1
0
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:
Jamie Hewitt 2021-05-13 17:35:57 +03:00
parent 137f57d5af
commit ad83649cb8

27
src/utils/rbac.ts Normal file
View 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)
}
}