I am very new to this style of coding. I am trying to not use express and doing some fetching in the front end. If things should never be done this way then let me know.
I know my endpoint is working but fetch seems to give me a strange internal server error now.
Before I was getting data. I'm basically lost on grabbing data in typescript and using the data in typescript. Let me know if anyone has suggestions on other ways to do this.
const wait = (ms) => new Promise(res => setTimeout(res, ms));
// TODO: figure out how get vars in here
async function getWorkerProfileData(searchQuery) {
let graphQuery = `
example
`
fetch("https://www.XXXX.com/graphql?query=" + graphQuery).then(function(response) {
console.log("ONE")
let myData = response.json();
/*
RETURNS THIS
Object {
"errors": Array [
Object {
"category": "internal",
"locations": Array [
Object {
"column": 20,
"line": 3,
},
],
"message": "Internal server error",
},
],
}
*/
console.log(response.json())
return myData;
}).then(function(json) {
console.log("tasdfasdfasdfasdf")
console.log(json);
return json;
});
}
const worker = getWorkerProfileData( "d29ya2VyOjI0ODE")
const GetWorkerProfile = <Props, State, worker > ({searchQuery}) => (
<Container>
{ console.log("DATA COMES BACK LIKE THIS: ", worker) }
/*
worker: Promise {
"_40": 0,
"_55": null,
"_65": 0,
"_72": null,
}
*/
<Content>
<List>
<View>
<Content>
<Header
subheader={ "test" }
content={ "test" }
/>
</Content>
</View>
</List>
</Content>
</Container>
);
export default GetWorkerProfile;