Skip to content

Commit 405ef58

Browse files
committed
chore: dev updates
1 parent 4b5f20b commit 405ef58

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

src/App.vue

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@
99
@focus="onEditorFocus"
1010
@blur="onEditorBlur"
1111
@imageAdded="handleImageAdded"
12-
@imageRemoved="handleImageRemoved"
12+
@image-removed="handleImageRemoved"
1313
/>
1414
</div>
1515
</template>
1616

1717
<script>
18-
import axiosInstance from "@/helpers/axios";
19-
console.log("TCL: axiosInstance", axiosInstance);
18+
// import axiosInstance from "@/helpers/axios";
19+
import axios from "axios";
2020
import Quill from "quill";
2121
const AlignStyle = Quill.import("attributors/style/align");
2222
Quill.register(AlignStyle, true);
2323
2424
const BlockEmbed = Quill.import("blots/block/embed");
2525
26+
const CLIENT_ID = "993793b1d8d3e2e";
27+
2628
/**
2729
* Customize image so we can add an `id` attribute
2830
*/
@@ -78,10 +80,15 @@ export default {
7880
const formData = new FormData();
7981
formData.append("image", file);
8082
81-
const result = await axiosInstance.post(`image`, { formData });
82-
console.log("ASYNC: handleImageAdded -> result", result);
83-
const { link, id } = result.data.data;
83+
const { data } = await axios({
84+
url: "https://api.imgur.com/3/image",
85+
method: "POST",
86+
headers: { Authorization: "Client-ID " + CLIENT_ID },
87+
data: formData
88+
});
89+
console.log("TCL: handleImageAdded -> data", data);
8490
91+
const { link, id } = data.data;
8592
Editor.insertEmbed(
8693
cursorLocation,
8794
"image",
@@ -91,25 +98,6 @@ export default {
9198
},
9299
Quill.sources.USER
93100
);
94-
// axios({
95-
// url: "https://api.imgur.com/3/image",
96-
// method: "POST",
97-
// headers: { Authorization: "Client-ID " + CLIENT_ID },
98-
// data: formData
99-
// })
100-
// .then(result => {
101-
// const { link, id } = result.data.data;
102-
// Editor.insertEmbed(
103-
// cursorLocation,
104-
// "image",
105-
// {
106-
// id,
107-
// url: link
108-
// },
109-
// Quill.sources.USER
110-
// );
111-
// })
112-
// .catch(err => console.log(err));
113101
},
114102
115103
handleImageRemoved(image) {

src/helpers/axios.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const CLIENT_ID = "993793b1d8d3e2e";
44
// We create our own axios instance and set a custom base URL.
55
// Note that if we wouldn't set any config here we do not need
66
// a named export, as we could just `import axios from 'axios'`
7-
const axiosInstance = axios.create({
7+
export const axiosInstance = axios.create({
88
baseURL: `https://api.imgur.com/3/`,
99
headers: { Authorization: "Client-ID " + CLIENT_ID }
1010
});
@@ -14,7 +14,7 @@ const axiosInstance = axios.create({
1414

1515
// Here we define a named export
1616
// that we can later use inside .js files:
17-
export default axiosInstance;
17+
// export default axiosInstance;
1818

1919
// axios({
2020
// url: "https://api.imgur.com/3/image",

0 commit comments

Comments
 (0)