Created
August 5, 2019 03:34
-
-
Save r3-yamauchi/e18f41a5d5bedf57592ecaf870507796 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getMovies = `query GetMovies{ | |
getMovies(id: 0) { | |
id | |
name | |
poster | |
date | |
plot | |
} | |
} | |
`; | |
const invokeGetMovie = async () => { | |
let req = new AWS.HttpRequest(appsyncUrl, env.AWS_REGION); | |
req.method = 'POST'; | |
req.headers.host = endpoint; | |
req.headers['Content-Type'] = 'multipart/form-data'; | |
req.body = JSON.stringify({ | |
query: getMovies, | |
operationName: 'GetMovies' | |
}); | |
let signer = new AWS.Signers.V4(req, 'appsync', true); | |
signer.addAuthorization(AWS.config.credentials, AWS.util.date.getDate()); | |
const result = await axios({ | |
method: 'post', | |
url: appsyncUrl, | |
data: req.body, | |
headers: req.headers | |
}); | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment