-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from just-codingbaby/react-정해찬-sprint5
[정해찬] sprint5
- Loading branch information
Showing
216 changed files
with
60,833 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
._.DS_Store | ||
**/.DS_Store | ||
**/._.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.