header.get is not a function. (Seed with simple TS) #324

Closed
opened 2026-03-13 07:41:49 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @productdevbook on GitHub (Dec 3, 2024).

The error I get when I try to send a seed through a simple TS.

betterAuth.api.signUpEmail({
      body: {
        email: 'test@test.com',
        password: 't9s{£A1$4!@t',
        name: 'test',
        username: 'test',
      },
      headers: {
        'Content-Type': 'application/json',
      },
    }).catch((error) => {
      console.error('Error creating user:', error)
    })
    console.log('userData', userData)
ERNAL_SERVER_ERROR internal server error] {
 status: 'INTERNAL_SERVER_ERROR',
 headers: Headers { 'Content-Type': 'application/json' },
 body: { message: 'internal server error', code: 'INTERNAL_SERVER_ERROR' },
 [cause]: { message: 'internal server error', code: 'INTERNAL_SERVER_ERROR' }
}
Error seeding database: TypeError: Cannot read properties of undefined (reading 'name')
Originally created by @productdevbook on GitHub (Dec 3, 2024). The error I get when I try to send a seed through a simple TS. ```ts betterAuth.api.signUpEmail({ body: { email: 'test@test.com', password: 't9s{£A1$4!@t', name: 'test', username: 'test', }, headers: { 'Content-Type': 'application/json', }, }).catch((error) => { console.error('Error creating user:', error) }) console.log('userData', userData) ``` ``` ERNAL_SERVER_ERROR internal server error] { status: 'INTERNAL_SERVER_ERROR', headers: Headers { 'Content-Type': 'application/json' }, body: { message: 'internal server error', code: 'INTERNAL_SERVER_ERROR' }, [cause]: { message: 'internal server error', code: 'INTERNAL_SERVER_ERROR' } } Error seeding database: TypeError: Cannot read properties of undefined (reading 'name') ```
Author
Owner

@Bekacru commented on GitHub (Dec 3, 2024):

headers needs to be a Header object. And you don't need to provide headers for seeding. but if you do provide it as

new Headers({
    //
})
@Bekacru commented on GitHub (Dec 3, 2024): headers needs to be a `Header` object. And you don't need to provide headers for seeding. but if you do provide it as ```ts new Headers({ // }) ```
Author
Owner

@productdevbook commented on GitHub (Dec 3, 2024):

yes, you're right. :D It's all my absent-mindedness

@productdevbook commented on GitHub (Dec 3, 2024): yes, you're right. :D It's all my absent-mindedness
Author
Owner

@productdevbook commented on GitHub (Dec 3, 2024):

Singup after create org. I'm missing something here, I need to add a header cookie but there is no cookie key value in the returned session.

    const organizationResponse = await authServer.api.createOrganization({
      body: {
        name: 'test',
        slug: 'test',
        userId,
      },
      headers: new Headers({
      })
    }).catch((error) => {
      console.error('Error creating organization:', error)
    }) as any

Error creating organization: [APIError [BetterCallAPIError]: API Error: UNAUTHORIZED ] {
  status: 'UNAUTHORIZED',
  headers: Headers {},
  body: { code: 'UNAUTHORIZED' },
  [cause]: undefined
}
@productdevbook commented on GitHub (Dec 3, 2024): Singup after create org. I'm missing something here, I need to add a header cookie but there is no cookie key value in the returned session. ``` const organizationResponse = await authServer.api.createOrganization({ body: { name: 'test', slug: 'test', userId, }, headers: new Headers({ }) }).catch((error) => { console.error('Error creating organization:', error) }) as any ``` ``` Error creating organization: [APIError [BetterCallAPIError]: API Error: UNAUTHORIZED ] { status: 'UNAUTHORIZED', headers: Headers {}, body: { code: 'UNAUTHORIZED' }, [cause]: undefined } ```
Author
Owner

@Bekacru commented on GitHub (Dec 3, 2024):

create organization is meant to be called with a valid authorized token for the time being. you can create the org directly using your orm and then create a member and assign it a role "owner", to replicate what this action would do.

@Bekacru commented on GitHub (Dec 3, 2024): create organization is meant to be called with a valid authorized token for the time being. you can create the org directly using your orm and then create a member and assign it a role "owner", to replicate what this action would do.
Author
Owner

@productdevbook commented on GitHub (Dec 3, 2024):

feature: What is the idea of creating a func where we can give a session to create an authorized token and get a token back?

@productdevbook commented on GitHub (Dec 3, 2024): feature: What is the idea of creating a func where we can give a session to create an authorized token and get a token back?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#324