Advertisement
Guest User

Untitled

a guest
Jul 8th, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. //Creating a payload to send to the API.
  2. const key = 'your key';
  3. const url = 'your url';
  4. const payload = {
  5. "question": workflow.userQ
  6. };
  7. //Creating a header to send the bearer token.
  8. const headers = {
  9. 'Authorization': key
  10. };
  11. //Calling the API using axios.
  12. axios.post(url, payload, { headers })
  13. .then(function (response) {
  14. //Setting the response in the state variable.
  15. workflow.apiResponse = response.data;
  16. //setResponse(JSON.stringify(response.data, null, 2));
  17. })
  18. .catch(function (error) {
  19. workflow.error = error;
  20. console.log(error);
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement