# setupProxy.js
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function (app) {
app.use(
'/api',
createProxyMiddleware({
target: 'https://test.zendesk.com',
changeOrigin: true
}),
);
};
import logo from './logo.svg';
import './App.css';
import axios from 'axios';
function App() {
return (
<div className="App">
<header className="App-header">
<button
onClick={() => {
// Zendesk API 인증 정보 설정
const encodedString = "/";
console.log(encodedString)
var config = {
method: 'GET',
url: '/api/v2/tickets',
headers: {
'Content-Type': 'application/json',
'Authorization': `Basic ${encodedString}`, // Base64 encoded "username:password"
// 'Authorization': 'Basic <auth-value>', // Base64 encoded "username:password"
},
// params: {
// 'external_id': '',
// },
};
axios(config).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.log(error);
});
}}
>zendesk</button>
</header>
</div>
);
}
export default App;
'프론트엔드 > React' 카테고리의 다른 글
[React] Full calendar 기본 세팅 (0) | 2022.02.19 |
---|---|
[React] 프로젝트 생성하기 (0) | 2022.02.12 |
[React] React Router - 'Switch' is not exported from 'react-router-dom' (0) | 2021.12.23 |
[React] Controlled vs Uncontrolled Component (0) | 2021.12.16 |