Hi, why this query works nice in the API but not in the Javascript-react view App.js?
… … … …
monday.api(‘query{boards(ids:1234567890){name id groups(ids:“topics”){title id items_page{cursor items {id name column_values {id text value }}}}}}’,
)
.then(res => {
this.setState({boardItems: res.data});
… … … …
The result is:
There was an error in response from monday.com graphql API: [{“message”:“Field ‘items_page’ doesn’t exist on type ‘Group’”,“locations”:[{“line”:1,“column”:68}],“path”:[“query”,“boards”,“groups”,“items_page”],“extensions”:{“code”:“undefinedField”,“typeName”:“Group”,“fieldName”:“items_page”}}]
The version is:
“data”: {
“version”: {
“kind”: “stable”,
“value”: “2023-10”
}
},
Thanks
Looks like the query in your React app does not specify the API version (2023-10) in the header of the request. You can specify the API version in different ways, one of them is:
monday.api(‘query{boards(ids:1234567890){name id groups(ids:“topics”){title id items_page{cursor items {id name column_values {id text value }}}}}}, {apiVersion: "2023-10"}’,
)
.then(res =>
Hi,
Thank you @basdebruin and Matias. And sorry for the delay.
It is a very good idea. But I have been trying the inclusion of
{apiVersion: “2023-10”}’,
and the Visual Studio Code shows that there are some sintaxis problem in the last “,”:
monday.api('query{boards(ids:5194314321){name id groups(ids:“topics”){title id items_page{cursor items {id name column_values {id text value }}}}}}, {apiVersion: “2023-10”}’,
)
So I have tried to use it in the API playgroud:
query {apiVersion: “2023-10” }
and the answer was:
“errors”: [
{
“message”: “Parse error on "2023-10" (STRING) at [2, 20]”,
“locations”: [
{
“line”: 2,
“column”: 20
}
]
}
],
Perhaps there are any mistake in my inclusion of your adding?
Thank you very much again
In the API Playground you specify the version over here:
In your ReactJS app you can use different options to set the version.
in the header
by using monday.setApiVersion("2023-10")
by using the method shown above
monday.api(‘query{boards(ids:1234567890){name id groups(ids:“topics”){title id items_page{cursor items {id name column_values {id text value }}}}}}, {apiVersion: "2023-10"})’
First, you were right with your diagnostic, @basdebruin . My API Playground is 2023-10. But the JavaScript-REACT app works on 2023-07. I wrote the version query in my App.js and the console.log said:
App.js:130 {data: {…}, account_id: 1234567}
account_id: 1234567
data: version: {kind: ‘deprecated’, value: ‘2023-07’}
[[Prototype]]: Object
[[Prototype]]: Object
But when I include the line: monday.setApiVersion(“2023-10”);
the error is now:
Uncaught TypeError: monday.setApiVersion is not a function
at App.handleSubmit (App.js:134:1)… … …
And when I use the other way with your query including {apiVersion: “2023-10”})’
The error is now:
There was an error in response from monday.com graphql API: [{“message”:“Parse error on "“" (error) at [1, 49]”,“locations”:[{“line”:1,“column”:49}]}]
So my App.js continues working in 2023-07 version.
I am going to see how to include the version set in the header
Thanks
Ok, I used the command:
$ npm install monday-sdk-js --save
With the result:
changed 1 package, and audited 1699 packages in 2m
62 packages are looking for funding
run npm fund for details
137 vulnerabilities (1 low, 102 moderate, 27 high, 7 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues possible (including breaking changes), run:
npm audit fix --force
Some issues need review, and may require choosing
a different dependency.
Run npm audit for details.
Unfortunately we still have the same error:
Uncaught TypeError: monday.setApiVersion is not a function
But I am not sure if it is the version 0.4.11. It is supposed that it will install the last version. How may know the version installed of this monday SDK package?
Hi @basdebruin. I did the npm update, but it still remains the same version of monday-sdk-js:
$ npm update
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient…
npm WARN old lockfile
up to date, audited 2042 packages in 1m
141 packages are looking for funding
run npm fund for details
123 vulnerabilities (1 low, 99 moderate, 20 high, 3 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues possible (including breaking changes), run:
npm audit fix --force
Some issues need review, and may require choosing
a different dependency.
Run npm audit for details.