PluginProbe
Extendify / 1.9.3
Extendify v1.9.3
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / src / Chat / api / Data.js

Data.js in Extendify 1.9.3, at src/Chat/api/Data.js

35 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Axios as api, restApi, wpHeaders } from './axios'
2
3 // Optionally add items to request body
4 const denyList = ['nonce', 'api']
5 const extraBody = {
6 ...Object.fromEntries(
7 Object.entries(window.extChatData).filter(
8 ([key]) => !denyList.includes(key),
9 ),
10 ),
11 }
12
13 export const getAnswer = ({ question, experienceLevel }) =>
14 fetch(`${window.extChatData.api}/ask-question`, {
15 method: 'POST',
16 headers: {
17 'Content-Type': 'application/json',
18 },
19 body: JSON.stringify({ question, experienceLevel, ...extraBody }),
20 })
21
22 export const rateAnswer = ({ answerId, rating }) =>
23 fetch(`${restApi}/chat/rate-answer`, {
24 method: 'POST',
25 headers: wpHeaders,
26 body: JSON.stringify({ answerId, rating }),
27 })
28
29 export const getOptions = () => api.get('chat/options')
30
31 export const updateOptions = (options) => api.post('chat/options', { options })
32
33 export const updateUserMeta = (user, option, value) =>
34 api.post('draft/update-user-meta', { user, option, value })
35