test: API 地址

2.0/email-builder
Lei OT 11 months ago
parent b3f50ecb90
commit d9c3721c2d

@ -22,7 +22,7 @@ export const fetchTemplates = async () => {
* @param {object} params { opisn }
*/
export const fetchConversationsList = async (params) => {
const { errcode, result: data } = await fetchJSON(`${API_HOST}/v2/getconversations`, params);
const { errcode, result: data } = await fetchJSON(`${API_HOST}/getconversations`, params);
if (errcode !== 0) return [];
const list = (data || []).map((ele) => ({ ...ele, customer_name: `${ele.whatsapp_name || ''}`.trim(), whatsapp_name: `${ele.whatsapp_name || ''}`.trim() }));
return list;
@ -74,7 +74,7 @@ export const postNewOrEditConversationItem = async (body) => {
Object.keys(body).forEach(function (key) {
formData.append(key, body[key]);
});
const { errcode, result } = await postForm(`${API_HOST}/v2/new_conversation`, formData);
const { errcode, result } = await postForm(`${API_HOST}/new_conversation`, formData);
if (errcode !== 0) {
return {};
}
@ -113,7 +113,7 @@ export const fetchConversationItemUnread = async (body) => {
* @param {object} body { conversationid, top_state }
*/
export const fetchConversationItemTop = async (body) => {
const { errcode, result } = await fetchJSON(`${API_HOST}/v2/set_top_conversation`, body);
const { errcode, result } = await fetchJSON(`${API_HOST}/set_top_conversation`, body);
return errcode !== 0 ? {} : result;
};
@ -213,7 +213,7 @@ export const postAssignConversation = async (params) => {
* @param {object} params { opisn, }
*/
export const fetchTags = async (params) => {
const { errcode, result } = await fetchJSON(`${API_HOST}/v2/get_opi_tags`, params);
const { errcode, result } = await fetchJSON(`${API_HOST}/get_opi_tags`, params);
return errcode !== 0 ? [] : result.map(ele => ({ label: ele.tag_label, key: ele.tag_key, value: ele.tag_key, }));
}
/**
@ -225,7 +225,7 @@ export const postConversationTags = async (body) => {
Object.keys(body).forEach(function (key) {
formData.append(key, body[key]);
});
const { errcode, result } = await postForm(`${API_HOST}/v2/set_conversation_tags_add`, formData);
const { errcode, result } = await postForm(`${API_HOST}/set_conversation_tags_add`, formData);
return errcode !== 0 ? {} : result[0];
}
/**
@ -233,7 +233,7 @@ export const postConversationTags = async (body) => {
* @param {object} params { opisn, conversationid, tag_id }
*/
export const deleteConversationTags = async (params) => {
const { errcode, result } = await fetchJSON(`${API_HOST}/v2/set_conversation_tags_del`, params);
const { errcode, result } = await fetchJSON(`${API_HOST}/set_conversation_tags_del`, params);
return errcode !== 0 ? {} : result;
}
/**

@ -4,7 +4,7 @@
// export const API_HOST = 'https://p9axztuwd7x8a7.mycht.cn/whatsapp_144';
// export const WS_URL = 'wss://p9axztuwd7x8a7.mycht.cn/whatsapp_144'; // prod: Slave
export const API_HOST = 'http://202.103.68.157:8889';
export const API_HOST = 'http://202.103.68.157:8889/v2';
// export const API_HOST = 'https://p9axztuwd7x8a7.mycht.cn/whatsapp_server';
export const WS_URL = 'wss://p9axztuwd7x8a7.mycht.cn/whatsapp_server'; // prod:
export const VONAGE_URL = 'https://p9axztuwd7x8a7.mycht.cn/vonage-server'; // 语音和视频接口:

@ -405,8 +405,8 @@ export const useConversationStore = create(
const conversationsList = await fetchConversationsList({ opisn: userIds });
addToConversationList(conversationsList);
// const templates = await fetchTemplates();
// setTemplates(templates);
const templates = await fetchTemplates();
setTemplates(templates);
// const closedList = await fetchConversationsSearch({ opisn: userIds, session_enable: 0 });
// setClosedConversationList(closedList);

@ -48,7 +48,7 @@ export function fetchText(url) {
export function fetchJSON(url, data) {
const params = data ? new URLSearchParams(data).toString() : '';
const ifp = url.includes('?') ? '&' : '?';
const ifp = url.includes('?') ? (data ? '&' : '') : '?';
const headerObj = getRequestHeader()
return fetch(`${url}${ifp}${params}`, {
method: 'GET',

Loading…
Cancel
Save