Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Creating a payload to send to the API.
- const key = 'your key';
- const url = 'your url';
- const payload = {
- "question": workflow.userQ
- };
- //Creating a header to send the bearer token.
- const headers = {
- 'Authorization': key
- };
- //Calling the API using axios.
- axios.post(url, payload, { headers })
- .then(function (response) {
- //Setting the response in the state variable.
- workflow.apiResponse = response.data;
- //setResponse(JSON.stringify(response.data, null, 2));
- })
- .catch(function (error) {
- workflow.error = error;
- console.log(error);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement