Closed sstone72389 closed 7 years ago
the request won't have a currentUser
stored in it
Look at your curl script syntax. Does anything look missing?
#!/bin/bash
API="http://localhost:4741"
URL_PATH="/buyers"
TOKEN="f2k4AWSsRMij0o/wIDWVscfrB0WuddJr4MhygBeH59Y=--yLhNbRQYXfOVD1CEWZIgs+TvqKTmucYJpVXSAwhBYmg="
curl "${API}${URL_PATH}" \
--include \
--request GET \
--header "Authorization: Token token=${TOKEN}" \
--header "Content-Type: application/json" \
echo
We had the syntax wrong to reference the token and had to change the model to user
const index = (req, res, next) => {
let owner = {_owner: req.user._id }
Buyer.find(owner)
.then(buyers => res.json({
buyers: buyers.map((e) =>
e.toJSON({ virtuals: true, user: req.user })),
}))
.catch(next);
};
We are having trouble getting a curl script to work for retrieving the buyer id. Please see applicable code snippets/error message below.
CURL script:
index method in controller:
Error message from server:
If we include authorization, the id should be retrievable. Any assistance would be greatly appreciated.