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 {
|
||||
const firstName = e.currentTarget.firstName.value || ''
|
||||
const lastName = e.currentTarget.lastName.value || ''
|
||||
const email = e.currentTarget.email.value
|
||||
|
||||
const apiResponse = await api.subscribeToMailingList(
|
||||
e.currentTarget.email.value,
|
||||
e.currentTarget.firstName.value + ' ' + e.currentTarget.lastName.value,
|
||||
)
|
||||
const apiResponse = await api.subscribeToMailingList({
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
})
|
||||
|
||||
setSuccessMessage(apiResponse.message)
|
||||
} catch (error) {
|
||||
|
|
|
@ -108,7 +108,7 @@ export default async function handler(
|
|||
|
||||
if (subscribed) {
|
||||
return res.status(200).json({
|
||||
message: 'already subscribed',
|
||||
message: 'Already subscribed',
|
||||
data: {},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -93,6 +93,13 @@ export class ApiService {
|
|||
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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue