Skip to content
Snippets Groups Projects
Commit f7720ab7 authored by DongHwi Kim's avatar DongHwi Kim
Browse files

connect react

parent 2fda3af3
Branches
No related tags found
No related merge requests found
......@@ -25,8 +25,6 @@ import kr.ajousw.myspringweb.service.MusicService;
@RestController
public class MyWebController{
private final RestTemplate restTemplate = new RestTemplate();
private final String BASE_URL = "<https://itunes.apple.com/search?entity=song&attribute=songTerm&term=>";
@Autowired
MusicService service;
......
package kr.ajousw.myspringweb.service;
import java.io.IOException;
import java.net.URI;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -24,19 +26,23 @@ public class MusicService {
RestTemplate restTemplate = new RestTemplate();
HttpServletRequest request;
public MusicList searchMusic(String name){
String url = "https://itunes.apple.com/search?term=" + name + "&entity=album";
RestTemplate restTemplate = new RestTemplate();
MusicList musicList = null;
try {
String jsonString = restTemplate.getForObject(request.getRequestURI(), String.class);
ObjectMapper objectMapper = new ObjectMapper();
musicList = objectMapper.readValue(jsonString, MusicList.class);
String response = restTemplate.getForObject(url, String.class);
ObjectMapper mapper = new ObjectMapper();
MusicList list = mapper.readValue(response, MusicList.class);
System.out.println(list.getResultCount());
return list;
} catch (IOException e) {
e.printStackTrace();
System.out.println(e.toString());
return null;
}
return musicList;
}
public List<FavoriteMusic> getLikes() {
try{
return albumsRepo.findAll();
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
<!doctype html>
<html>
<head>
<title> muiBasic </title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
</head>
<body>
<div id="app"></div>
<script src="./app.bundle.js" type="text/javascript"></script>
</body>
</html>
\ No newline at end of file
No preview for this file type
No preview for this file type
Source diff could not be displayed: it is too large. Options to address this: view the blob.
<!doctype html>
<html>
<head>
<title> muiBasic </title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
</head>
<body>
<div id="app"></div>
<script src="./app.bundle.js" type="text/javascript"></script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment