Code is here, probably not complex. This code is just hitting the API to get the tasks of a certain worker in a certain workspace in Asana.

import asana from "asana";

const GetAsanaData = () => {
  const personalAccessToken = `Bearer 1/1200...`;
  const workspace = "1200...";
  const assignee = "12007...";
  const opt_fields = ["name", "completed", "completed_at"];

  const client = asana.Client.create().useAccessToken(personalAccessToken);
  const result = client.tasks
    .getTasks({
      workspace: workspace,
      assignee: assignee,
      opt_fields: opt_fields,
    })
    .then((response) => response);
  return result;
};

export default GetAsanaData;

First error says;

Could not find a declaration file for module 'asana'. 'C:/Users/81906/Documents/polygon-hr/node_modules/asana/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/asana if it exists or add a new declaration (.d.ts) file containing declare module 'asana';ts(7016)

Then I followed this error and then second error happens and says;

Property 'getTasks' does not exist on type 'Tasks'. Did you mean 'getTask'?ts(2551) index.d.ts(2060, 13): 'getTask' is declared here.

Indeed, if I looked at the referenced index.d.ts(2060, 13), there are no getTasks instead of getTask. However, the official documentation (https://developers.asana.com/docs/get-multiple-tasks) says to call it this way... Is it a bug in the library?


After that, I modified as follows;

// before
import asana from "asana";
↓
// after
const asana = require("asana");

Then this error in title disappeared but another error happened as below.

Failed to compile
./node_modules/readline/readline.js:1:0
Module not found: Can't resolve 'fs'

Import trace for requested module:
./node_modules\asana\lib\auth\native_flow.js
./node_modules\asana\lib\auth\index.js
./node_modules\asana\index.js
./services\asanaService.tsx
./components\RadarChart.tsx
./pages\index.tsx

https://nextjs.org/docs/messages/module-not-found

Converting import to require itself was correct?? If so, should I struggle with this new error "Module not found: Can't resolve 'fs'"?

0

There are 0 best solutions below