import React, { Component } from 'react' import UploadImage from './lib/uploadImage.component' import { post } from './util' const initialState = { 'image': null, 'res': null, 'loading': false, } export default class PhashApp extends Component { state = { ...initialState } upload(blob) { if (this.state.image) { URL.revokeObjectURL(this.state.image) } const url = URL.createObjectURL(blob) this.setState({ image: url, loading: true }) const fd = new FormData() fd.append('q', blob) post('/api/v1/match', fd) .then(res => { console.log(res) this.setState({ res, loading: false }) }) .catch(err => { console.log(err) this.setState({ loading: false }) }) } render() { return (