Cant get board using sails.helpers.boards.getProjectPath #340

Closed
opened 2026-02-04 18:36:05 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @7rory768 on GitHub (Jun 30, 2023).

I am creating a new api controller create.js and for some reason boardA comes back as undefined even though sails.helpers.boards.getProjectPath is returning the board successfully

create.js:

  async fn(inputs) {
    const { currentUser } = this.req;

    console.log('boards-sync create.js: ', inputs);

    const { boardA } = await sails.helpers.boards
      .getProjectPath(inputs.boardA)
      .intercept('pathNotFound', () => Errors.BOARD_NOT_FOUND);

    console.log('boardA: ', boardA);

helpers.boards.get-project-path.js (added debug)

  async fn(inputs) {
    console.log('board: get project path', inputs);

    const board = await Board.findOne(inputs.criteria);

    if (!board) {
      console.log('board: get project path - failed to find board', inputs.criteria);
      throw 'pathNotFound';
    }

    const project = await Project.findOne(board.projectId);

    if (!project) {
      console.log('board: get project path - failed to find project', board);
      throw {
        pathNotFound: {
          board,
        },
      };
    }

    console.log('board: get project path - returning', {
      board,
      project,
    });

    return {
      board,
      project,
    };
  },
};

console output:

[server] boards-sync create.js:  { boardA: '981379214949221381', boardB: '981545914072040472' }
[server] board: get project path { criteria: '981379214949221381' }
[server] board: get project path - returning {
[server]   board: {
[server]     id: '981379214949221381',
[server]     createdAt: 2023-05-15T20:05:18.000Z,
[server]     updatedAt: null,
[server]     position: 65535,
[server]     name: 'Test',
[server]     projectId: '981379159232087043'
[server]   },
[server]   project: {
[server]     id: '981379159232087043',
[server]     createdAt: 2023-05-15T20:05:12.000Z,
[server]     updatedAt: 2023-06-28T17:35:49.000Z,
[server]     name: 'Test',
[server]     background: { name: 'sky-change', type: 'gradient' },
[server]     backgroundImage: null
[server]   }
[server] }
[server] boardA:  undefined
Originally created by @7rory768 on GitHub (Jun 30, 2023). I am creating a new api controller create.js and for some reason boardA comes back as undefined even though sails.helpers.boards.getProjectPath is returning the board successfully **create.js:** ```JS async fn(inputs) { const { currentUser } = this.req; console.log('boards-sync create.js: ', inputs); const { boardA } = await sails.helpers.boards .getProjectPath(inputs.boardA) .intercept('pathNotFound', () => Errors.BOARD_NOT_FOUND); console.log('boardA: ', boardA); ``` **helpers.boards.get-project-path.js (added debug)** ```JS async fn(inputs) { console.log('board: get project path', inputs); const board = await Board.findOne(inputs.criteria); if (!board) { console.log('board: get project path - failed to find board', inputs.criteria); throw 'pathNotFound'; } const project = await Project.findOne(board.projectId); if (!project) { console.log('board: get project path - failed to find project', board); throw { pathNotFound: { board, }, }; } console.log('board: get project path - returning', { board, project, }); return { board, project, }; }, }; ``` console output: ``` [server] boards-sync create.js: { boardA: '981379214949221381', boardB: '981545914072040472' } [server] board: get project path { criteria: '981379214949221381' } [server] board: get project path - returning { [server] board: { [server] id: '981379214949221381', [server] createdAt: 2023-05-15T20:05:18.000Z, [server] updatedAt: null, [server] position: 65535, [server] name: 'Test', [server] projectId: '981379159232087043' [server] }, [server] project: { [server] id: '981379159232087043', [server] createdAt: 2023-05-15T20:05:12.000Z, [server] updatedAt: 2023-06-28T17:35:49.000Z, [server] name: 'Test', [server] background: { name: 'sky-change', type: 'gradient' }, [server] backgroundImage: null [server] } [server] } [server] boardA: undefined ```
Author
Owner

@7rory768 commented on GitHub (Jun 30, 2023):

silly mistake in my syntax

@7rory768 commented on GitHub (Jun 30, 2023): silly mistake in my syntax
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/planka#340