@@ -297,19 +297,18 @@ export class AtlasUserData<T extends z.Schema> extends IUserData<T> {
297297
298298 const response = await this . authenticatedFetch (
299299 this . getResourceUrl (
300- `userData/${ this . dataType } /${ this . orgId } /${ this . projectId } `
300+ `userData/${ this . dataType } /${ this . orgId } /${ this . projectId } / ${ id } `
301301 ) ,
302302 {
303303 method : 'POST' ,
304304 headers : {
305305 'Content-Type' : 'application/json' ,
306306 } ,
307307 body : JSON . stringify ( {
308- id : id ,
309308 data : this . serialize ( content ) ,
310309 createdAt : new Date ( ) ,
311- projectId : this . projectId ,
312310 } ) ,
311+ credentials : 'include' ,
313312 }
314313 ) ;
315314
@@ -344,6 +343,7 @@ export class AtlasUserData<T extends z.Schema> extends IUserData<T> {
344343 ) ,
345344 {
346345 method : 'DELETE' ,
346+ credentials : 'include' ,
347347 }
348348 ) ;
349349 if ( ! response . ok ) {
@@ -381,6 +381,7 @@ export class AtlasUserData<T extends z.Schema> extends IUserData<T> {
381381 ) ,
382382 {
383383 method : 'GET' ,
384+ credentials : 'include' ,
384385 }
385386 ) ;
386387 if ( ! response . ok ) {
@@ -424,7 +425,11 @@ export class AtlasUserData<T extends z.Schema> extends IUserData<T> {
424425 headers : {
425426 'Content-Type' : 'application/json' ,
426427 } ,
427- body : this . serialize ( newData ) ,
428+ body : JSON . stringify ( {
429+ data : this . serialize ( newData ) ,
430+ createdAt : new Date ( ) ,
431+ } ) ,
432+ credentials : 'include' ,
428433 }
429434 ) ;
430435 if ( ! response . ok ) {
@@ -450,14 +455,15 @@ export class AtlasUserData<T extends z.Schema> extends IUserData<T> {
450455 }
451456
452457 // TODO: change this depending on whether or not updateAttributes can provide all current data
453- async readOne ( id : string ) : Promise < z . output < T > > {
458+ async readOne ( id : string ) : Promise < z . output < T > | undefined > {
454459 try {
455460 const getResponse = await this . authenticatedFetch (
456461 this . getResourceUrl (
457462 `userData/${ this . dataType } /${ this . orgId } /${ this . projectId } /${ id } `
458463 ) ,
459464 {
460465 method : 'GET' ,
466+ credentials : 'include' ,
461467 }
462468 ) ;
463469 if ( ! getResponse . ok ) {
@@ -480,7 +486,6 @@ export class AtlasUserData<T extends z.Schema> extends IUserData<T> {
480486 error : ( error as Error ) . message ,
481487 }
482488 ) ;
483- return null ;
484489 }
485490 }
486491}
0 commit comments