Search code examples
loopbackjsstrongloop

strongloop loopback GET ressource/exists vs HEAD ressource


With strongloop's loopback default REST API for persisted model, what is the difference between doing:

  • HEAD Ressource/{id}
  • GET Ressource/{id}/exists

?


Solution

  • This was an interesting question. I checked out and found out only two difference.

    Exist API

    http://0.0.0.0:3001/api/brands/1/exists
    

    returns

    {
      "exists": true
    }
    

    or

    {
      "exists": false
    }
    

    Response Code is 200 for both conditions.

    HEAD API

    http://0.0.0.0:3001/api/brands/1
    

    returns no content on both condition.

    Response Code is 200 when exists and 404 when doesn't exists.