Skip to content

Commit

Permalink
update proxy & fix space encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-mba committed Sep 7, 2023
1 parent 2766df4 commit 07aaad3
Show file tree
Hide file tree
Showing 16 changed files with 17 additions and 488 deletions.
Binary file removed docs/assets/color.473bc8ca.png
Binary file not shown.
178 changes: 0 additions & 178 deletions docs/assets/index.05f67a6a.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/assets/index.1b396a02.css

This file was deleted.

Binary file removed docs/assets/primeicons.131bc3bf.ttf
Binary file not shown.
Binary file removed docs/assets/primeicons.3824be50.woff2
Binary file not shown.
292 changes: 0 additions & 292 deletions docs/assets/primeicons.5e10f102.svg

This file was deleted.

Binary file removed docs/assets/primeicons.90a58d3a.woff
Binary file not shown.
Binary file removed docs/assets/primeicons.ce852338.eot
Binary file not shown.
Binary file removed docs/favicon.ico
Binary file not shown.
1 change: 0 additions & 1 deletion docs/index.html

This file was deleted.

4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<script setup>
import {ref, watch} from 'vue';
import NHTSA from './constants/endpoints';
import getUrl from './constants/endpoints';
import YearSelect from './components/YearSelect';
import MakeSelect from './components/MakeSelect';
import ModelSelect from './components/ModelSelect';
Expand Down Expand Up @@ -64,7 +64,7 @@ function getData() {
vehicle.value = null;
return;
}
fetch(`${NHTSA.proxy}?quest=${NHTSA.endpoint}/VehicleId/${vehId.value}`)
fetch(getUrl(`/VehicleId/${vehId.value}`))
.then(res => res.json())
.then(response => {
const data = response.Results[0];
Expand Down
4 changes: 2 additions & 2 deletions src/components/DescSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script setup>
import {ref, watch} from 'vue';
import NHTSA from '../constants/endpoints';
import getUrl from '../constants/endpoints';
const props = defineProps({
value: {type: String, default: ''},
Expand Down Expand Up @@ -51,7 +51,7 @@ watch (selected, () => {
function getData() {
selected.value = '';
fetch(`${NHTSA.proxy}?quest=${NHTSA.endpoint}/modelyear/${props.year}/make/${props.make}/model/${props.model}`)
fetch(getUrl(`/modelyear/${props.year}/make/${props.make}/model/${props.model}`))
.then(res => res.json())
.then(response => {
descriptions.value = response.Results.map(result => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/MakeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script setup>
import {ref, watch} from 'vue';
import NHTSA from '../constants/endpoints';
import getUrl from '../constants/endpoints';
const props = defineProps({
value: {type: String, default: ''},
Expand All @@ -29,7 +29,7 @@ watch(() => props.year, () => {
return;
}
selected.value = '';
fetch(`${NHTSA.proxy}?quest=${NHTSA.endpoint}/modelyear/${props.year}`)
fetch(getUrl(`/modelyear/${props.year}`))
.then(res => res.json())
.then(response => {
makes.value = response.Results.map(result => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/ModelSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script setup>
import {ref, watch} from 'vue';
import NHTSA from '../constants/endpoints';
import getUrl from '../constants/endpoints';
const props = defineProps({
value: {type: String, default: ''},
Expand Down Expand Up @@ -47,12 +47,12 @@ watch (selected, () => {
});
function getData() {
fetch(`${NHTSA.proxy}?quest=${NHTSA.endpoint}/modelyear/${props.year}/make/${props.make}`)
fetch(getUrl(`/modelyear/${props.year}/make/${props.make}`))
.then(res => res.json())
.then(response => {
models.value = response.Results.map(result => {
return {
value: result.Model.replace(/&/g,'_'),
value: result.Model.replace(/&/g,'_').replace(/ /g,'%20'),
text: result.Model
}
})
Expand Down
4 changes: 2 additions & 2 deletions src/components/YearSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script setup>
import {ref, watch, onMounted} from 'vue';
import NHTSA from '../constants/endpoints';
import getUrl from '../constants/endpoints';
defineProps({
value: {type: String, default: ''}
Expand All @@ -27,7 +27,7 @@ watch(selected, () => {
});
onMounted(() => {
fetch(`${NHTSA.proxy}?quest=${NHTSA.endpoint}`)
fetch(getUrl(''))
.then(res => res.json())
.then(response => {
years.value = response.Results.map(result => {
Expand Down
11 changes: 6 additions & 5 deletions src/constants/endpoints.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const NHTSA = {
endpoint: 'api.nhtsa.gov/SafetyRatings',
proxy: 'https://api.codetabs.com/v1/proxy/'
};
export default NHTSA;
const endpoint = 'https://api.nhtsa.gov/SafetyRatings';
const proxy = 'https://corsproxy.io/?';

export default function getUrl (URLPart){
return proxy + encodeURIComponent(`${endpoint}${URLPart}`);
}

0 comments on commit 07aaad3

Please sign in to comment.