I'm trying to get data from sanity but when I try to fetch its causing an error. Here is my code ...
useEffect(() => {
const query = '*[_type=="abouts"]';
client.fetch(query).then((data) => setAbouts(data));
}, []);
ERROR:
request.js:28 Uncaught (in promise) ClientError {response: {…}, statusCode: 401, responseBody: '{\n "message": "Session not found",\n "error": "Un…"errorCode": "SIO-401-ANF",\n "statusCode": 401\n}', message: 'Unauthorized - Session not found', name: 'ClientError', …}response: {body: {…}, url: 'https://noa7mgdi.apicdn.sanity.io/v2022-09-06/data…y/production?query=*%5B_type%3D%3D%22abouts%22%5D', method: 'GET', headers: {…}, statusCode: 401, …}responseBody: "{\n \"message\": \"Session not found\",\n \"error\": \"Unauthorized\",\n \"errorCode\": \"SIO-401-ANF\",\n \"statusCode\": 401\n}"statusCode: 401message: "Unauthorized - Session not found"name: "ClientError"stack: "ClientError: Unauthorized - Session not found\n
at onResponse .onResponse (http://localhost:3000/static/js/bundle.js:3328:13 undefined)\n
at applyMiddleware .applyMiddleware (http://localhost:3000/static/js/bundle.js:8680:23 undefined)\n
at onResponse .onResponse (http://localhost:3000/static/js/bundle.js:7911:22 undefined)\n at http://localhost:3000/static/js/bundle.js:7880:16\n
at onLoad .onLoad (http://localhost:3000/static/js/bundle.js:8522:5 undefined)\n
at xhr.<computed> (http://localhost:3000/static/js/bundle.js:8385:5 undefined)"[[Prototype]]: BaseError