mirror of
https://github.com/EvolutionAPI/evolution-manager.git
synced 2025-07-21 11:37:24 -06:00
verify url before connect
This commit is contained in:
parent
303ede0ba1
commit
d10417960f
@ -33,7 +33,7 @@ export const useAppStore = defineStore('app', {
|
|||||||
async setConnection({ host, globalApiKey }) {
|
async setConnection({ host, globalApiKey }) {
|
||||||
try {
|
try {
|
||||||
this.connecting = true
|
this.connecting = true
|
||||||
const responde = await axios({
|
const response = await axios({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
baseURL: host,
|
baseURL: host,
|
||||||
headers: {
|
headers: {
|
||||||
@ -43,9 +43,11 @@ export const useAppStore = defineStore('app', {
|
|||||||
url: '/instance/fetchInstances'
|
url: '/instance/fetchInstances'
|
||||||
})
|
})
|
||||||
|
|
||||||
this.saveConnection({ host, globalApiKey })
|
if (!response.data || !Array.isArray(response.data)) throw new Error('Essa conexão não é uma instância da evolution-api')
|
||||||
|
|
||||||
this.instancesList = responde.data
|
|
||||||
|
this.saveConnection({ host, globalApiKey })
|
||||||
|
this.instancesList = response.data
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.connection.valid = false
|
this.connection.valid = false
|
||||||
throw e.response?.data?.response?.message || e.response || e
|
throw e.response?.data?.response?.message || e.response || e
|
||||||
|
Loading…
Reference in New Issue
Block a user