This commit is contained in:
leejinseok
2020-02-14 11:54:57 +09:00
parent 76b669c737
commit 189a541e95
2 changed files with 14 additions and 12 deletions

View File

@@ -3,37 +3,37 @@ import axios from 'axios';
export default {
getArticles({page = 0, size = 10, q = ''}, authorization) {
const request = axios({
const options = {
url: '/api/articles',
params: {
page,
size,
q
}
});
};
if (authorization) {
request.headers = {
options.headers = {
'Authorization': authorization
};
}
return request;
return axios(options);
},
getArticle({articleId}, authorization) {
const request = axios({
const options = {
url: '/api/articles/' + articleId,
});
};
if (authorization) {
request.headeres = {
options.headers = {
'Authorization': authorization
}
}
return request;
console.log(options);
return axios(options);
},
postArticle({title = '', content = ''}, authorization) {

View File

@@ -20,9 +20,11 @@ export default {
},
async getArticle(articleId) {
try {
const authorization = commonUtil.getAuthenticationHeaderBearer(this.$cookie.get('accessToken'));
const result = await articleApi.getArticle({articleId}, authorization);
return result.data;
const accessToken = this.$cookie.get('accessToken');
const authorization = commonUtil.getAuthenticationHeaderBearer(accessToken);
const {data} = await articleApi.getArticle({articleId}, authorization);
return data;
} catch (err) {
alert('문제가 발생하였습니다.');
console.log(err);