auth header and env setup
This commit is contained in:
parent
a30557327d
commit
9f71cda86b
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,6 +10,7 @@
|
||||
|
||||
# production
|
||||
/build
|
||||
.env
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -5350,9 +5350,9 @@
|
||||
}
|
||||
},
|
||||
"dotenv": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
|
||||
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
|
||||
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q=="
|
||||
},
|
||||
"dotenv-expand": {
|
||||
"version": "5.1.0",
|
||||
@ -12872,6 +12872,11 @@
|
||||
"workbox-webpack-plugin": "5.1.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
|
||||
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
|
||||
},
|
||||
"sass-loader": {
|
||||
"version": "10.2.0",
|
||||
"resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-10.2.0.tgz",
|
||||
@ -16895,4 +16900,4 @@
|
||||
"integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
"@testing-library/react": "^11.2.7",
|
||||
"@testing-library/user-event": "^12.8.3",
|
||||
"bootstrap": "^4.6.0",
|
||||
"dotenv": "^10.0.0",
|
||||
"eslint": "^7.27.0",
|
||||
"form-data": "^4.0.0",
|
||||
"moment": "^2.29.1",
|
||||
@ -47,4 +48,4 @@
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
export const fetchProfile = async (link, index) => {
|
||||
try {
|
||||
const response = await fetch(`${link}${index}`)
|
||||
const response = await fetch(`${link}${index}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`
|
||||
}
|
||||
})
|
||||
let data = await response.json()
|
||||
|
||||
return data
|
||||
@ -9,7 +13,11 @@ export const fetchProfile = async (link, index) => {
|
||||
|
||||
export const fetchSkills = async (link) => {
|
||||
try {
|
||||
const response = await fetch(link)
|
||||
const response = await fetch(link, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`
|
||||
}
|
||||
})
|
||||
let data = await response.json()
|
||||
|
||||
return data
|
||||
@ -18,7 +26,11 @@ export const fetchSkills = async (link) => {
|
||||
|
||||
export const fetchItemsForId = async (link, id) => {
|
||||
try {
|
||||
const response = await fetch(`${link}${id}`)
|
||||
const response = await fetch(`${link}${id}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`
|
||||
}
|
||||
})
|
||||
let data = await response.json()
|
||||
|
||||
return data
|
||||
@ -30,6 +42,7 @@ export const fetchForm = async (link, info) => {
|
||||
const response = await fetch(link, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
body: info
|
||||
@ -40,14 +53,16 @@ export const fetchForm = async (link, info) => {
|
||||
}
|
||||
|
||||
export const fetchAuth = async ({ username, password, dispatch }) => {
|
||||
const baseURL = process.env.REACT_APP_BASE_URL;
|
||||
const apiURL = process.env.REACT_APP_API_URL;
|
||||
try {
|
||||
const response = await fetch(
|
||||
'https://guild.craft-group.xyz/api/user/login',
|
||||
`${apiURL}/api/user/login`,
|
||||
{
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
'Origin': `${baseURL}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username,
|
||||
|
Loading…
Reference in New Issue
Block a user