fix addition link to input

master
timka 2023-11-22 22:39:54 +03:00
parent 541545b166
commit cd88541981
3 changed files with 7 additions and 10 deletions

View File

@ -1,4 +1,3 @@
import logo from './logo.svg';
import './App.css'; import './App.css';
import {BrowserRouter, Routes, Route} from "react-router-dom"; import {BrowserRouter, Routes, Route} from "react-router-dom";

View File

@ -22,17 +22,14 @@ class AddLink extends Component {
if (this.state.value === "") { if (this.state.value === "") {
return return
} }
const linkName = this.createLink(this.state.value) var linkName = makeid(6)
console.log(linkName) this.createLink(this.state.value, linkName)
this.setState({value: `https://timka.su/${linkName}`}) this.setState({value: `https://timka.su/${linkName}`})
} }
createLink(url) { createLink(url, linkName) {
axios.post("https://link.timka.su", return axios.post("https://link.timka.su",
{name: makeid(6), url: url}).then(function (response) { {name: linkName, url: url})
console.log(response.data.name)
return `${response.data.name}`
})
} }
render () { render () {

View File

@ -4,6 +4,7 @@ import {React, Component} from "react";
class NotFound extends Component { class NotFound extends Component {
render () { render () {
return <h2>Not found</h2> return <h2>Not found</h2>
// todo add design
} }
} }