Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SFR-2263: Add error logging for Airtable API #541

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGE LOG

## [Prerelease]

- Add error logging for Airtable API

## [0.18.4]

- Update license link for editions, works, and collections to copyright
Expand Down
33 changes: 20 additions & 13 deletions src/lib/api/FeedbackApi.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
import appConfig from "~/config/appConfig";
import { Feedback } from "~/src/types/Feedback";
import { log } from "../newrelic/NewRelic";

// TODO: disable feedback in development

export const submitFeedback = async (feedback: Feedback) => {
return await fetch(appConfig.feedback.formURL, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.NEXT_PUBLIC_AIRTABLE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
fields: {
Feedback: feedback.feedback,
Category: feedback.category,
URL: feedback.url,
try {
const res = await fetch(appConfig.feedback.formURL, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.NEXT_PUBLIC_AIRTABLE_API_KEY}`,
"Content-Type": "application/json",
},
}),
});
body: JSON.stringify({
fields: {
Feedback: feedback.feedback,
Category: feedback.category,
URL: feedback.url,
},
}),
});
return res;
} catch (error) {
log(error, "Airtable API error");
throw new Error(`Airtable POST failed: ${error.message}`);
}
};
Loading