Problem when request with axios to api go lang. Error decode NOSQL

Viewed 22

i have this issue, when i try to post with axios in my front-ent to my back-end in go lang showed this:

timed out while checking out a connection from connection pool: context canceled; maxPoolSize: 100, connections in use by cursors: 0, connections in use by transactions: 0, connections in use by other operations: 1

I did print for see if the information was correct and is all right. The error ocorres when Try to Decode the information of my result of MongoDB in go lang. But this only happened when I do it with front. If I call directly like with postman... I don't have problem.

My service that calls mongoDB.

func (p *profile)CheckInformationValid(ctx echo.Context,email string, password string, profile *models.Profile)  (string, error) {

    filter := map[string]interface{}{"Email": email, "PassWord": password}
    result := storage.GetInstance().FindOne(ctx, "profile",filter)

    fmt.Println(result)
    if result == nil {
        return  "", errors.New("Check Information: user not find")
    }

    err := result.Decode(profile)
    if err != nil {
        fmt.Println(err)
        return "",errors.New("Error Decode Profile") 
    }

    fmt.Println(profile)

    log.Infof("[CheckInformationValid] Object : %s \n", profile, "")

    return profile.UserId , nil
}

the erros ocorrer in result.Decode.

my front:

export async function validLogin(email, password) { 

  const data = JSON.stringify({ email, password });
  let headers = {
    'Content-Type': 'application/json;charset=UTF-8',
  };

  return await axios.post('http://localhost:1323/profile/valid', data, headers)
}
0 Answers
Related