debugging madness
This commit is contained in:
parent
4212b3b159
commit
dc55e51ec9
|
@ -110,9 +110,10 @@ export async function updateLingdocsUser(uuid: T.UUID, toUpdate:
|
||||||
const user = await getLingdocsUser("userId", uuid);
|
const user = await getLingdocsUser("userId", uuid);
|
||||||
if (!user) throw new Error("unable to update - user not found " + uuid);
|
if (!user) throw new Error("unable to update - user not found " + uuid);
|
||||||
if ("tests" in toUpdate) {
|
if ("tests" in toUpdate) {
|
||||||
|
const newTests = toUpdate.tests.filter((t) => !user.tests.some(x => x.time === t.time));
|
||||||
return await insertLingdocsUser({
|
return await insertLingdocsUser({
|
||||||
...user,
|
...user,
|
||||||
tests: [...user.tests, ...toUpdate.tests],
|
tests: [...user.tests, ...newTests],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ("password" in toUpdate) {
|
if ("password" in toUpdate) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/lingdocs-main",
|
"name": "@lingdocs/lingdocs-main",
|
||||||
"version": "0.1.4",
|
"version": "0.1.5",
|
||||||
"description": "types and functions for lingdocs stuff",
|
"description": "types and functions for lingdocs stuff",
|
||||||
"main": "dist/library.js",
|
"main": "dist/library.js",
|
||||||
"module": "dist/library.js",
|
"module": "dist/library.js",
|
||||||
|
|
|
@ -36,6 +36,7 @@ export async function updateUserTextOptionsRecord(userTextOptionsRecord: AT.User
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function postTestResults(tests: AT.TestResult[]): Promise<AT.PostTestResultsResponse> {
|
export async function postTestResults(tests: AT.TestResult[]): Promise<AT.PostTestResultsResponse> {
|
||||||
|
console.log("inside post test results, gonna call myfetch");
|
||||||
const response = await myFetch("account", "user/tests", "PUT", { tests }) as AT.PostTestResultsResponse;
|
const response = await myFetch("account", "user/tests", "PUT", { tests }) as AT.PostTestResultsResponse;
|
||||||
console.log("response from posting test results", response);
|
console.log("response from posting test results", response);
|
||||||
return response;
|
return response;
|
||||||
|
@ -72,6 +73,7 @@ export async function myFetch(
|
||||||
// better typing and safety of all this
|
// better typing and safety of all this
|
||||||
body?: FT.SubmissionsRequest | { password: string } | AT.UpdateUserTextOptionsRecordBody | AT.PostTestResultsBody,
|
body?: FT.SubmissionsRequest | { password: string } | AT.UpdateUserTextOptionsRecordBody | AT.PostTestResultsBody,
|
||||||
): Promise<AT.APIResponse> {
|
): Promise<AT.APIResponse> {
|
||||||
|
console.log("inside my fetch")
|
||||||
const response = await fetch(baseUrl[service] + url, {
|
const response = await fetch(baseUrl[service] + url, {
|
||||||
method,
|
method,
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
|
@ -82,7 +84,9 @@ export async function myFetch(
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
} : {},
|
} : {},
|
||||||
});
|
});
|
||||||
|
console.log("response from my fetch", response);
|
||||||
const text = await response.text();
|
const text = await response.text();
|
||||||
|
console.log("as text", text);
|
||||||
try {
|
try {
|
||||||
return JSON.parse(text);
|
return JSON.parse(text);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in New Issue