question about "data migration/user creation"; doe...
# general
f
question about "data migration/user creation"; does this have to be done using cURL requests?
r
hey @funk101
yea it does. We don't have functions in the backend SDK for those. But you can always just use fetch / axios in your backend code as well
f
hmm
I'm getting this error:
Copy code
[Symbol(Response internals)]: {
    url: 'https://dev-5adad1716e1211ed8e078d5042b64ab1-us-east-1.aws.supertokens.io:3567/recipe/user/passwordhash/import',
    status: 401,
    statusText: 'Unauthorized',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}
I "assume" I'm using the correct api-key
r
api key is wrong
f
don't I use the "core api key"?
that's the only key I have
I just re-checked
r
right. You are querying the dev instance. So are you using the dev API key?
f
yes
r
well.. is your app working when connected to the dev instance?
f
yes
r
then there is some issue with how you are making the API call
im not sure what. It's on you to figure
f
Copy code
const url =
  "https://dev-5adad1716e1211ed8e078d5042b64ab1-us-east-1.aws.supertokens.io:3567/recipe/user/passwordhash/import";

const response = fetch(url, {
  method: "post",
  body: JSON.stringify({
    email: "jeff@jeffrenza.com",
    passwordHash:
      "$argon2i$v=19$m=16,t=2,p=1$TG9qbzU1NzE$rTOXWfhHVT+Q7wPn7PShSQ",
  }),
  headers: {
    "Content-Type": "application/json",
    api_key: "<my key>",
  },

});
response.then((res) => console.log("res: ", res));
r
it's
api-key
not
api_key
f
argh
r
haha yeaa..
f
yep, that was it, sorry 😭
r
no worries. happy to help
f
So the response from that above logic doesn't send back the newly created supertokensId, right? I don' t see it in the response
r
it does.
f
I don't see it, point me in the direction?
Copy code
Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: null
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://dev-5adad1716e1211ed8e078d5042b64ab1-us-east-1.aws.supertokens.io:3567/recipe/user/email/verify/token',
    status: 200,
    statusText: 'OK',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}
oops, wrong response, that's for verification, hang on...
Copy code
Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: null
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://dev-5adad1716e1211ed8e078d5042b64ab1-us-east-1.aws.supertokens.io:3567/recipe/user/passwordhash/import',
    status: 400,
    statusText: 'Bad Request',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}
again, that was a bad request, here's the response
Copy code
Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: null
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://dev-5adad1716e1211ed8e078d5042b64ab1-us-east-1.aws.supertokens.io:3567/recipe/user/passwordhash/import',
    status: 200,
    statusText: 'OK',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}
r
you might wanna read on up how read response body from fetch API call
f
duh, got it thanks