Skip to content

Commit

Permalink
Merge pull request #91 from just-codingbaby/react-정해찬-sprint5
Browse files Browse the repository at this point in the history
[정해찬] sprint5
  • Loading branch information
coldplay126 authored Oct 29, 2024
2 parents fd58012 + 12831cc commit b33b11b
Show file tree
Hide file tree
Showing 216 changed files with 60,833 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
._.DS_Store
**/.DS_Store
**/._.DS_Store
56 changes: 56 additions & 0 deletions pandamarket/api/ArticleService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import axios from "axios";

const ARTICLE_BASE_URL = 'https://sprint-mission-api.vercel.app/articles';

axios.interceptors.request.use (
function(request) {
console.log('Request Interceptor 성공: ',request.method);
return request;
},
function(error) {
if(error.response) {
console.log('Request Interceptor 에러 발생: ',error.response.status);
return error;
}
}
)

axios.interceptors.response.use (
function(response) {
console.log('Response Interceptor 성공: ',response.status);
console.log(response.data);
return response;
},
function(error) {
if(error.response) {
console.log('Response Interceptor 에러 발생: ',error.response.status);
return error;
}
}
)

export async function apiRequest(method,url,data = {},params = {}) {
const config = {method, url, data, params};
const response = await axios(config);
return response.data;
}

export async function getArticleList(keyword) {
return apiRequest('GET', ARTICLE_BASE_URL, {},{page:'1',pageSize:'100',keyword});
}

export async function getArticle(id) {
return apiRequest('GET',`${ARTICLE_BASE_URL}/${id}`);
}

export async function createArticle(title,content,image) {
return apiRequest('POST',ARTICLE_BASE_URL,{title,content,image});
}

export async function patchArticle(id,title,content,image) {
return apiRequest('PATCH',`${ARTICLE_BASE_URL}/${id}`,{title,content,image});
}

export async function deleteArticle(id) {
return apiRequest('DELETE',`${ARTICLE_BASE_URL}/${id}`);
}
24 changes: 24 additions & 0 deletions pandamarket/api/ProductService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { apiRequest } from "./ArticleService.js";

const PRODUCTS_BASE_URL = 'https://sprint-mission-api.vercel.app/products';

export async function getProductList(keyword) {
return apiRequest('GET', PRODUCTS_BASE_URL, {}, {page:'1', pagsSize:'100', keyword});
}

export async function getProduct(id) {
return apiRequest('GET',`${PRODUCTS_BASE_URL}/${id}`);
}

export async function createProduct(name,description,price,manufacturer,tags,images) {
return apiRequest('POST',PRODUCTS_BASE_URL,{name,description,price,manufacturer,tags,images});
}

export async function patchProduct(id,name,description,price,tags,images) {
return apiRequest('PATCH',`${PRODUCTS_BASE_URL}/${id}`,{name,description,price,tags,images});
}

export async function deleteProduct(id) {
return apiRequest('DELETE',`${PRODUCTS_BASE_URL}/${id}`);
}

8 changes: 8 additions & 0 deletions pandamarket/api/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getArticle, getArticleList, createArticle, patchArticle, deleteArticle } from "./ArticleService.js";
import { getProduct,getProductList,createProduct, patchProduct, deleteProduct } from "./ProductService.js";

getArticle(90);
getArticleList('정몽규');
createArticle('정해찬','test','test_image');
patchArticle(776,'patch_정해찬','patch_test','patch_image');
deleteArticle(776);
97 changes: 97 additions & 0 deletions pandamarket/api/node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pandamarket/api/node_modules/asynckit/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b33b11b

Please sign in to comment.