aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2022-06-09 11:01:09 +0000
committerterminaldweller <thabogre@gmail.com>2022-06-09 11:01:09 +0000
commit52d31b5b35e1d44b8dbffd516b28547ddad611a1 (patch)
tree7a15bb355aa801d096a8dd60aa7362e1c00a3fea
parentadded config file (diff)
downloadmdrtl-52d31b5b35e1d44b8dbffd516b28547ddad611a1.tar.gz
mdrtl-52d31b5b35e1d44b8dbffd516b28547ddad611a1.zip
server link
-rw-r--r--spring-front/src/components/Editor.js72
-rw-r--r--spring-front/src/config.js2
2 files changed, 33 insertions, 41 deletions
diff --git a/spring-front/src/components/Editor.js b/spring-front/src/components/Editor.js
index 5f561b8..b77be1e 100644
--- a/spring-front/src/components/Editor.js
+++ b/spring-front/src/components/Editor.js
@@ -134,7 +134,7 @@ export default class Editor extends React.Component {
// DELETE
handleDelete() {
- fetch(`https://localhost:9080/api/v1/doc/${this.docId}`, {
+ fetch(mdrtlConfig.serverURL + this.docId, {
method: "DELETE",
headers: {
Accept: "application/json",
@@ -149,22 +149,20 @@ export default class Editor extends React.Component {
// GET
handleLoad(event) {
let res;
- fetch(`https://localhost:9080/api/v1/doc/${this.docId}`).then(
- (response) => {
- if (!response.ok) {
- throw new Error(`request failed with status ${response.status}`);
- }
- res = response.json().then((json) => {
- this.setState({ value: json.body });
- let result_element = document.getElementById("highlight-content");
- result_element.textContent = this.state.value;
- let element = document.getElementById("markdown-placeholder");
- let htm = md.render(this.state.value);
- element.innerHTML = htm;
- this.updateCodeSyntaxHighlighting();
- });
+ fetch(mdrtlConfig.serverURL + this.docId).then((response) => {
+ if (!response.ok) {
+ throw new Error(`request failed with status ${response.status}`);
}
- );
+ res = response.json().then((json) => {
+ this.setState({ value: json.body });
+ let result_element = document.getElementById("highlight-content");
+ result_element.textContent = this.state.value;
+ let element = document.getElementById("markdown-placeholder");
+ let htm = md.render(this.state.value);
+ element.innerHTML = htm;
+ this.updateCodeSyntaxHighlighting();
+ });
+ });
}
// POST & PUT
@@ -175,18 +173,15 @@ export default class Editor extends React.Component {
lastModified: Math.floor(Date.now() / 1000),
body: this.state.value,
};
- let response = await fetch(
- `https://localhost:9080/api/v1/doc/${this.docId}`,
- {
- method: "POST",
- body: JSON.stringify(obj),
- mode: "cors",
- headers: {
- Accept: "application/json",
- "Content-Type": "application/json",
- },
- }
- );
+ let response = await fetch(mdrtlConfig.serverURL + this.docId, {
+ method: "POST",
+ body: JSON.stringify(obj),
+ mode: "cors",
+ headers: {
+ Accept: "application/json",
+ "Content-Type": "application/json",
+ },
+ });
if (!response.ok) {
let obj = {
@@ -195,18 +190,15 @@ export default class Editor extends React.Component {
lastModified: Math.floor(Date.now() / 1000),
body: this.state.value,
};
- let response = await fetch(
- `https://localhost:9080/api/v1/doc/${this.docId}`,
- {
- method: "PUT",
- body: JSON.stringify(obj),
- mode: "cors",
- headers: {
- Accept: "application/json",
- "Content-Type": "application/json",
- },
- }
- );
+ let response = await fetch(mdrtlConfig.serverURL + this.docId, {
+ method: "PUT",
+ body: JSON.stringify(obj),
+ mode: "cors",
+ headers: {
+ Accept: "application/json",
+ "Content-Type": "application/json",
+ },
+ });
if (!response.ok) {
throw new Error(`request failed with status code ${response.status}`);
diff --git a/spring-front/src/config.js b/spring-front/src/config.js
index a2f9bc4..e74952d 100644
--- a/spring-front/src/config.js
+++ b/spring-front/src/config.js
@@ -1,3 +1,3 @@
export const mdrtlConfig = {
- serverURL: "apimdrtl.terminaldweller.com",
+ serverURL: "editorsave.terminaldweller.com/api/v1/doc/",
};