24 lines
607 B
JavaScript
24 lines
607 B
JavaScript
// models/odoo/index.js
|
|
import axios from "axios";
|
|
import { odooConfig } from "../../config/odooConfig.js";
|
|
|
|
export const JSON_RPC_URL = `${odooConfig.url}/jsonrpc`;
|
|
|
|
export const authenticate = async () => {
|
|
const payload = {
|
|
jsonrpc: "2.0",
|
|
method: "call",
|
|
params: {
|
|
service: "common",
|
|
method: "login",
|
|
args: [odooConfig.db, odooConfig.email, odooConfig.apiKey],
|
|
},
|
|
id: 1,
|
|
};
|
|
|
|
const { data } = await axios.post(JSON_RPC_URL, payload);
|
|
return data.result;
|
|
};
|
|
|
|
export { odooConfig }; // re-export for other modules
|