feathersjs - TypeScript kullanarak feathers-chat eğitiminde hata mesajı alınıyor "Error: 'users.get' metoduna bir id verilmelidir"
Feathers rehber sayfasındaki tüyler sohbeti (https://docs.feathersjs.com/guides/basics/generator.html#generating-the-application) eğitimini takip ediyorum ve uygulama testlerden birinde başarısız oluyor.
**NOT: TypeScript sürümünü takip ediyorum ama MongoDB'ye bağlanmak için mongoose kullanıyorum**
İşte hata mesajı
1) 'messages' service
creates and processes message, adds user information:
Error: An id must be provided to the 'users.get' method
at Object.validate (node_modules/@feathersjs/feathers/lib/hooks/base.js:23:11)
at /Users/fabriciobracht/Documents/cpsc2650/feathers-chat/node_modules/@feathersjs/commons/src/hooks.ts:132:47
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at addUser (src/hooks/populate-user.ts:13:20)
at Object.<anonymous> (src/hooks/populate-user.ts:28:24)
at Context.<anonymous> (test/services/messages.test.ts:20:21)
Çıktı günlüğü temelde aynı bilgileri içeriyor. Yani, geriye doğru gidersek, hata test çalışırken bu satırda oluşuyor (messages.test.ts:20:21)
const params = { user };
const message = await app.service('messages').create({
text: 'a test',
additional: 'should be removed'
}, params);
Hangi çağrılar populate-user.ts'yi çağırıyor
export default (): Hook => {
return async (context: HookContext) => {
// Get `app`, `method`, `params` and `result` from the hook context
const { app, method, result, params } = context;
// Function that adds the user to a single message object
const addUser = async (message: any) => {
// Get the user based on their id, pass the `params` along so
// that we get a safe version of the user data
const user = await app.service('users').get(message.userId, params);
// Merge the message content to include the `user` object
return {
...message,
user
};
};
// In a find method we need to process the entire page
if (method === 'find') {
// Map all data to include the `user` information
context.result.data = await Promise.all(result.data.map(addUser));
} else {
// Otherwise just update the single result
context.result = await addUser(result);
}
return context;
};
}
Ama işte tam burada kafam karışıyor. Biri bu konuda biraz ışık tutabilir mi? Teşekkürler