簡體   English   中英

Feathers js如何自定義獲取服務端點

[英]Feathers js how to customize get service endpoint

所以我想將 url 附加到我在另一個服務中的用戶請求中。 如何自定義獲取請求?

const { Service } = require('feathers-sequelize')

exports.Users = class Users extends Service {
  get(id, params) {
    // how to add custom data into to the get result?
    return super.get(id, params)
  }
}

您從super中檢索值並返回一個新的 object:

const { Service } = require('feathers-sequelize')

exports.Users = class Users extends Service {
  async get(id, params) {
    // how to add custom data into to the get result?
    const data = await super.get(id, params)

    return {
      ...data,
      // when using raw: false:
      // ...data.toJSON(),
      message: 'New data here'
    }
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM