fix: use new api version for subscription
This commit is contained in:
parent
17f716c6ce
commit
f9d219c40e
|
@ -69,11 +69,13 @@ export default function SubscribeDialogue({
|
||||||
try {
|
try {
|
||||||
const firstName = e.currentTarget.firstName.value || ''
|
const firstName = e.currentTarget.firstName.value || ''
|
||||||
const lastName = e.currentTarget.lastName.value || ''
|
const lastName = e.currentTarget.lastName.value || ''
|
||||||
|
const email = e.currentTarget.email.value
|
||||||
|
|
||||||
const apiResponse = await api.subscribeToMailingList(
|
const apiResponse = await api.subscribeToMailingList({
|
||||||
e.currentTarget.email.value,
|
email,
|
||||||
e.currentTarget.firstName.value + ' ' + e.currentTarget.lastName.value,
|
firstName,
|
||||||
)
|
lastName,
|
||||||
|
})
|
||||||
|
|
||||||
setSuccessMessage(apiResponse.message)
|
setSuccessMessage(apiResponse.message)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -108,7 +108,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (subscribed) {
|
if (subscribed) {
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
message: 'already subscribed',
|
message: 'Already subscribed',
|
||||||
data: {},
|
data: {},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,13 @@ export class ApiService {
|
||||||
body: JSON.stringify(payload),
|
body: JSON.stringify(payload),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (res.status >= 400) {
|
||||||
|
// Handle errors for status codes 400 and 500
|
||||||
|
const errorMessage = `Error: ${res.status} - ${res.statusText}`
|
||||||
|
console.error(errorMessage)
|
||||||
|
throw new Error(errorMessage)
|
||||||
|
}
|
||||||
|
|
||||||
return res.json()
|
return res.json()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue