Ensure console requests include project header

A change recently to Appwrite required all API calls to include the project
ID.
This commit is contained in:
Steven Nguyen committed 2023-07-25 17:32:35 -07:00
1 parent d48bc96bde
commit afe4dfa9ec
5 files changed
+17 -4

No files matched your search

+6 -1
View File
@@ -2,7 +2,12 @@ import { sdk } from '$lib/stores/sdk';
import type { LayoutLoad } from './$types';
export const load: LayoutLoad = async () => {
const response = await fetch(`${sdk.forConsole.client.config.endpoint}/health/version`);
const { endpoint, project } = sdk.forConsole.client.config;
const response = await fetch(`${endpoint}/health/version`, {
headers: {
'X-Appwrite-Project': project
}
});
const data = await response.json();
return {
@@ -56,8 +56,12 @@ export const versions = cachedStore<
>('versions', function ({ set }) {
return {
load: async () => {
const { endpoint } = sdk.forConsole.client.config;
const response = await fetch(`${endpoint}/../versions`);
const { endpoint, project } = sdk.forConsole.client.config;
const response = await fetch(`${endpoint}/../versions`, {
headers: {
'X-Appwrite-Project': project
}
});
set(await response.json());
}
};
@@ -74,6 +74,7 @@
'PATCH',
new URL(sdk.forConsole.client.config.endpoint + path),
{
'X-Appwrite-Project': sdk.forConsole.client.config.project,
'content-type': 'application/json'
},
{
@@ -20,6 +20,7 @@
sdk.forConsole.client.config.endpoint + '/projects/' + $project.$id + '/team'
),
{
'X-Appwrite-Project': sdk.forConsole.client.config.project,
'content-type': 'application/json'
},
{
@@ -54,9 +54,11 @@
async function invite() {
try {
const res = await fetch(`${sdk.forConsole.client.config.endpoint}/account/invite`, {
const { endpoint, project } = sdk.forConsole.client.config;
const res = await fetch(`${endpoint}/account/invite`, {
method: 'POST',
headers: {
'X-Appwrite-Project': project,
'Content-Type': 'application/json'
},
body: JSON.stringify({