i have API Documentation built with GraphQL API, with some of search i find tutorial but its not enough. the api contain authorization. like below: Login
mutation {
login(
input: {
username: "customer",
password: "123456",
}
){
token
}
}
and the header Headers after login
authorization: Bearer(login token),
content-language: ‘ar’
and the endpoint its subdomain http://accuratess.holol-aldiar.com.sa/
all i need its fetch data with javascript to qury the data
query {
shipment(id: 1) {
id
code
customerDue
timeFrom
timeTo
latitude
longitude
collected
paidToCustomer
paidToDeliveryAgent
deletable
createdAt
description
weight
piecesCoun
}
}
its shipment tracking
and the js code:
fetch('http://accuratess.holol-aldiar.com.sa', {
mode: 'no-cors',
method: 'POST',
headers:{"Content-Type": "application/json"},
body: JSON.stringify({
query:`
query {
shipment(id: 1) {
id
code
customerDue
}
}
`
})
}).then(res => res.json()).then(
data =>{
console.log(data.data)
}
)