-
Notifications
You must be signed in to change notification settings - Fork 5
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 #74 from Steven90411/develop
新增文章編輯中tag和導入作者id功能
- Loading branch information
Showing
26 changed files
with
441 additions
and
61 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
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
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
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
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
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
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
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
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
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
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,38 @@ | ||
import { API_BASE_URL } from './apiConfig'; | ||
|
||
const getToken = () => { | ||
return localStorage.getItem('token'); | ||
}; | ||
|
||
const getUserInfo = async () => { | ||
const token = getToken(); | ||
if (token) { | ||
try { | ||
const response = await fetch(`${API_BASE_URL}/protected-endpoint`, { | ||
method: 'GET', | ||
headers: { | ||
'Authorization': `Bearer ${token}` | ||
} | ||
}); | ||
|
||
if (response.ok) { | ||
const data = await response.json(); | ||
return data; | ||
} else { | ||
throw new Error('Failed to fetch user info'); | ||
} | ||
} catch (error) { | ||
console.error('Error fetching user info:', error); | ||
throw error; | ||
} | ||
} else { | ||
throw new Error('No token found'); | ||
} | ||
}; | ||
|
||
const authService = { | ||
getToken, | ||
getUserInfo | ||
}; | ||
|
||
export default authService; |
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,19 @@ | ||
import axios from "axios"; | ||
|
||
const API_BASE_URL = 'http://localhost:8080/blog/api/tags'; | ||
|
||
const getArticleTag = async (articleId) => { | ||
const response = await axios.get(`http://localhost:8080/blog/api/articles/${articleId}/tag`); | ||
return response.data; | ||
} | ||
|
||
const getAllTags = async () => { | ||
const response = await axios.get(`${API_BASE_URL}/all`); | ||
return response.data; | ||
} | ||
|
||
const tagService ={ | ||
getArticleTag, | ||
getAllTags | ||
} | ||
export default tagService; |
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,2 @@ | ||
// src/services/apiConfig.js | ||
export const API_BASE_URL = 'http://localhost:8080/blog/api'; |
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
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
Oops, something went wrong.