chore: Update Fetcher and TokenManager to use API v1
This commit is contained in:
parent
1d0f9ed1ed
commit
989137211e
3 changed files with 8 additions and 8 deletions
|
@ -22,7 +22,8 @@ const signUp = (username, password, displayName, email) => {
|
|||
}
|
||||
|
||||
const UpdatePassword = newPassword => {
|
||||
return fetch(`/users/change_password`, {
|
||||
const baseURL = apiManager.getApiURL()
|
||||
return fetch(`${baseURL}/users/change_password`, {
|
||||
method: 'PUT',
|
||||
headers: HEADERS(),
|
||||
body: JSON.stringify({ password: newPassword }),
|
||||
|
@ -403,21 +404,20 @@ const ResetPassword = email => {
|
|||
}
|
||||
|
||||
const UpdateDueDate = (id, dueDate) => {
|
||||
return Fetch(`/chores/${chore.id}/dueDate`, {
|
||||
return Fetch(`/chores/${id}/dueDate`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
dueDate: newDate ? new Date(newDate).toISOString() : null,
|
||||
UpdatedBy: activeUserId,
|
||||
dueDate: dueDate ? new Date(dueDate).toISOString() : null,
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
const RefreshToken = () => {
|
||||
const basedURL = apiManager.getApiURL()
|
||||
return fetch(basedURL + '/auth/refresh', {
|
||||
return fetch(`${basedURL}/auth/refresh`, {
|
||||
method: 'GET',
|
||||
headers: HEADERS(),
|
||||
})
|
||||
|
|
|
@ -6,7 +6,7 @@ import { Preferences } from '@capacitor/preferences'
|
|||
|
||||
class ApiManager {
|
||||
constructor() {
|
||||
this.customServerURL = API_URL
|
||||
this.customServerURL = `${API_URL}/api/v1`
|
||||
this.initialized = false
|
||||
}
|
||||
async init() {
|
||||
|
@ -17,7 +17,7 @@ class ApiManager {
|
|||
key: 'customServerUrl',
|
||||
})
|
||||
|
||||
this.customServerURL = serverURL || API_URL
|
||||
this.customServerURL = `${serverURL || API_URL}/api/v1`
|
||||
this.initialized = true
|
||||
}
|
||||
getApiURL() {
|
||||
|
|
|
@ -204,7 +204,7 @@ const ChoreCard = ({
|
|||
alert('Please select a performer')
|
||||
return
|
||||
}
|
||||
UpdateDueDate.then(response => {
|
||||
UpdateDueDate(chore.id, newDate).then(response => {
|
||||
if (response.ok) {
|
||||
response.json().then(data => {
|
||||
const newChore = data.res
|
||||
|
|
Loading…
Add table
Reference in a new issue