Skip to content

Commit

Permalink
fix cors
Browse files Browse the repository at this point in the history
  • Loading branch information
Aserus committed Jun 21, 2021
1 parent 3ef5059 commit 1735c41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/api/makepdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ import axios from 'axios'
name
html
*/
export default function postToServer(data) {
axios({
export default async function postToServer(data) {
const response = await axios({
method: 'post',
url: 'localhost:4500/api/htmlToPdf',
url: 'http://localhost:4500/api/htmlToPdf',
responseType: 'blob',
data
});
const downloadUrl = window.URL.createObjectURL(new Blob([response.data]));

const link = document.createElement('a');
link.href = downloadUrl;
link.setAttribute('download', 'generate.pdf');
document.body.appendChild(link);
link.click();
link.remove();
}
2 changes: 1 addition & 1 deletion src/components/RenderPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default {
style: css,
})
console.log(html)
postToServer(html)
postToServer({html})
}
}
}
Expand Down

0 comments on commit 1735c41

Please sign in to comment.