integrate digitalocean api

This commit is contained in:
Michael Fatemi 2021-07-08 00:59:09 -04:00
parent 08e0a0aed2
commit 14c4ded29e
3 changed files with 12 additions and 5 deletions

3
.env
View File

@ -1 +1,2 @@
REACT_APP_API_ENDPOINT=http://localhost:5000/api REACT_APP_API_ENDPOINT_0=http://localhost:5000/api
REACT_APP_API_DOMAIN=https://wheelshare-altbackend-2efyw.ondigitalocean.app/

View File

@ -1,5 +1,9 @@
const domain = process.env.REACT_APP_API_DOMAIN;
console.log({ domain });
export async function createSession(code: string, redirectUrl: string) { export async function createSession(code: string, redirectUrl: string) {
const res = await fetch('http://localhost:5000/create_session', { const res = await fetch(domain + 'create_session', {
method: 'post', method: 'post',
body: JSON.stringify({ code, redirectUrl }), body: JSON.stringify({ code, redirectUrl }),
headers: { headers: {

View File

@ -2,8 +2,10 @@ import { IEventSignup } from './Event';
import { GroupPreview } from './GroupJoinerLink'; import { GroupPreview } from './GroupJoinerLink';
import { IInvitation } from './types'; import { IInvitation } from './types';
const base = process.env.REACT_APP_API_DOMAIN + 'api';
async function post(path: string, data: any) { async function post(path: string, data: any) {
const res = await fetch('http://localhost:5000/api' + path, { const res = await fetch(base + path, {
method: 'post', method: 'post',
body: JSON.stringify(data), body: JSON.stringify(data),
headers: { headers: {
@ -15,7 +17,7 @@ async function post(path: string, data: any) {
} }
async function delete$(path: string) { async function delete$(path: string) {
const res = await fetch('http://localhost:5000/api' + path, { const res = await fetch(base + path, {
method: 'delete', method: 'delete',
headers: { headers: {
Authorization: 'Bearer ' + localStorage.getItem('session_token'), Authorization: 'Bearer ' + localStorage.getItem('session_token'),
@ -26,7 +28,7 @@ async function delete$(path: string) {
} }
async function get(path: string) { async function get(path: string) {
const res = await fetch('http://localhost:5000/api' + path, { const res = await fetch(base + path, {
headers: { headers: {
Authorization: 'Bearer ' + localStorage.getItem('session_token'), Authorization: 'Bearer ' + localStorage.getItem('session_token'),
}, },