Skip to content

Instantly share code, notes, and snippets.

View filesEndpointClient.js
import Axios from "axios";
import { API_URL } from "../models/constants";
export const uploadImage = async (token, imageUrl) => {
const fileBlob = await urlToObject(imageUrl);
var bodyFormData = new FormData();
bodyFormData.append('file', fileBlob);
View CreateUserPage.jsx
import React, { useState } from 'react';
import getToken from '../api_client/auth';
import { uploadImage } from '../api_client/files';
import { createUser } from '../api_client/user';
import '../App.css';
const CreateUserPage = () => {
const [publicName, setPublicName] = useState("");
const [password, setPassword] = useState("");
const [email, setEmail] = useState("");
View userHelper.php
<?php
/**
* This is a short snapshot to show an idea. The complete project is tored here:
* https://github.com/wildroo/medium/blob/main/react_php_task
*/
class UserHelper{
private $usersTable = "users";
private $profilesTable = "profiles";
View userEndpoint.php
<?php
header("Content-Type: application/json; charset=UTF-8");
include_once '../config/dbconfig.php';
include_once '../helpers/userHelper.php';
$db = new DBClass();
$userHelper = new UserHelper();
//$data = $connection->query('SELECT NOW()');
//print_r($data);
@wildroo
wildroo / dbconfig.php
Created Jul 5, 2021
DB Config PHP File
View dbconfig.php
<?php
class DBClass {
private $host = "<your_host>";
private $username = "<your_user_name>";
private $password = "<your_passowrd>";
private $database = "<your_db_name>";
public $connection;