0

The following code only get the return of makeLogin, without the brackets. But it was working before i migrate the files to another directory.

const { access_token } = await new AuthService()
        .makeLogin(login)
jeanpdt
  • 38
  • 5

1 Answers1

1

const { varName } is a destructuring assignment, meaning it takes the value at the key "varName" in the Object returned by the function and assigns it to a local variable called varName. If the function returns an object, which is the only way to validly destructure the value, then using const varName would put the whole object into the local variable called varName.

const func = () => ({ varName: "value" })
const { varName } = func()
// varName === "value"
const varName2 = func()
// varName2 === { varName: "value" }
Jeremi G
  • 397
  • 1
  • 8